0

How does this work???

x=6; y=2 if x>6.0 else 3 print (y) Output: 3 How is 6.0 larger than 6???

27th Jul 2022, 6:20 PM
MrFantastic
MrFantastic - avatar
4 Answers
+ 3
Not larger. that's why 3. ***There are equal.
27th Jul 2022, 6:28 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
6 > 6.0 is false, hence y = 3
27th Jul 2022, 6:23 PM
Lisa
Lisa - avatar
0
Missed the else šŸ¤¦, thanks guys
27th Jul 2022, 8:10 PM
MrFantastic
MrFantastic - avatar
- 1
Maybe it will be clearer like this: y = (2 if x>6.0 else 3) And no, 6 is not greater than 6.0, so 3 šŸ˜‰
27th Jul 2022, 6:33 PM
Solo
Solo - avatar