Can anyone explain the reason of the answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone explain the reason of the answer

while [()]: print("1") else: print("2")

11th May 2020, 5:01 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
2 Answers
+ 2
[()] is a list that contains an empty tuple. An empty list has falsy value, a non empty list has truthy value. In this case the list is not empty, so the while loop will repeat for ever.
11th May 2020, 5:08 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Thanks for answering
11th May 2020, 5:13 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar