How does this code work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does this code work?

a, b = 5, 6 c = (a, b) [a<b] print(c) output: 6

2nd Oct 2022, 2:36 PM
Shantanu
Shantanu - avatar
1 Answer
+ 4
a<b is True int(True) returns 1 , index is type int. Automatically type casted. so (a, b) [a<b] => (a, b)[1] => 6
2nd Oct 2022, 2:52 PM
Jayakrishna 🇮🇳