Possible Duplicate:
Ternary conditional operator in Python
I’ve programmed in Java for quite sometime, I’m learning Python in school and I remember in Java for a boolean expression you could do
boolean ? (if boolean is true this happens) : (if boolean is false this happens)
Is their a way to do the above Java code in Python? And what is the statement above properly called?
Yes, you can use this (more pythonic):
Or, this (more common, but not recommended):