+ 1
And what is the reason of this answer
while (()): print("1") else: print ("2")
11 Answers
0
You can try out such stuff here in Code Playground:
https://code.sololearn.com/c93cK6be0wHp/?ref=app
+ 2
The else is executed when while is false.
Here to have it maybe easier to understand. While gets executed 3 times, then else.
i = 0
while (i < 3):
print ("1")
i += 1
else:
print ("2")
If you break the loop instead of getting false in while condition the else does not executed.
+ 1
For all collections (Strings, dicts, arrays, tuples, etc.) empty collections are considered as False, non-empty as True.
+ 1
[()] contains an element, so is not empty.
0
As there isn't any value in the loop while, it jump to the else, next print 2.. give me a like if i'm rigth dude :')
0
Not satisfying
0
I want reason on (()) this ([]) what will be the output in both condition and why
Anyone!
0
Just saw, this is a duplicate question:
https://www.sololearn.com/discuss/2288328/?ref=app
0
Are you sure
0
What happens if [()] is use in while loop
0
Yes right