+ 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
3 ответов
+ 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