Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python では、複数行のラムダ関数をどのように記述できますか。私は試した
d = lambda x: if x: return 1 else return 2
しかし、私はエラーが発生しています...
これがあなたがやろうとしていることの正しいバージョンです:
d = lambda x: 1 if x else 2
しかし、なぜあなたがそれをしたいのかわかりません。