inline if statement python
- Last modified: 15 February 2020
- Category: python tutorial
Inline if statement
1 2 3 | x = 1 z = 'yes!' if x == 1 else 'no' print(z) |
output
1 | yes! |
Same example with normal if statement
1 2 3 4 5 6 7 8 | x = 1 if x == 1: z = 'yes!' print(z) else: z = 'no!' print(z) |
output
1 | yes! |
English today is not an art to be mastered it's just a tool to use to get a result