0

If statement

What is the difference between: X = 1 if X == 1: print(‘foo!’) if X <= 2: print(‘eggs’) As opposed to X = 1 if X == 1: print(‘foo!’) if X <= 2: print(‘eggs’)

7th Feb 2019, 1:50 AM
Asri Sapari
Asri Sapari - avatar
2 odpowiedzi
+ 1
This case it is no difference cause x=1 but if x<=2 and x! =1 then in first code there isn't output in second code it outputs 'eggs'
7th Feb 2019, 3:15 AM
Vladimir Medvedev
Vladimir Medvedev - avatar
+ 1
Put it in code playground and try yourself
7th Feb 2019, 1:19 PM
Gordon
Gordon - avatar