+ 1

How to put 2 if statement with different conditions in a single line using print() function ?

1st May 2021, 7:49 AM
Levi
Levi - avatar
3 Respostas
+ 1
age = 25 print('Kid' if age < 18 else ( 'Adult' if age < 60 else 'Old'))
1st May 2021, 8:27 AM
Asmerom Estifanos
Asmerom Estifanos - avatar
+ 5
a = 2 b = 3 c = 4 print(a if a > b else b if b > c else c)
1st May 2021, 8:21 AM
ChaoticDawg
ChaoticDawg - avatar
0
Hi! please, show us at least your sample code, the task is not quite clear. have you tried doing it yourself?
1st May 2021, 7:57 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar