Putting a simple if-then statement on one line

That's more specifically a ternary operator expression than an if-then, here's the python syntax
value_when_true if condition else value_when_false

Better Example:
'Yes' if fruit == 'Apple' else 'No'

No comments:

Post a Comment