one liner if else replacement in python 1

one liner if else replacement in python

>>> a = "Hello" if foo() else "Goodbye"

Here is what the above code is Doing:
1. The first line is a comment.
2. The second line is a variable assignment.
3. The third line is a function definition.
4. The fourth line is a function call.
5. The fifth line is a conditional expression.
6. The sixth line is a variable assignment.

Similar Posts