Answers for "elif comprehension method python"

1

python list comprehension elif

>>> l = [1, 2, 3, 4, 5]
>>> ['yes' if v == 1 else 'no' if v == 2 else 'idle' for v in l]
['yes', 'no', 'idle', 'idle', 'idle']
Posted by: Guest on November-16-2020

Code answers related to "elif comprehension method python"

Python Answers by Framework

Browse Popular Code Answers by Language