+ 1

And what is the reason of this answer

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

11th May 2020, 5:21 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
11 RĂ©ponses
0
You can try out such stuff here in Code Playground: https://code.sololearn.com/c93cK6be0wHp/?ref=app
11th May 2020, 5:56 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 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.
11th May 2020, 5:46 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 1
For all collections (Strings, dicts, arrays, tuples, etc.) empty collections are considered as False, non-empty as True.
11th May 2020, 5:51 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 1
[()] contains an element, so is not empty.
11th May 2020, 5:57 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
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 :')
11th May 2020, 5:39 PM
Liam @addliam
Liam @addliam - avatar
0
Not satisfying
11th May 2020, 5:44 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
I want reason on (()) this ([]) what will be the output in both condition and why Anyone!
11th May 2020, 5:48 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
Just saw, this is a duplicate question: https://www.sololearn.com/discuss/2288328/?ref=app
11th May 2020, 5:48 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
Are you sure
11th May 2020, 5:52 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
What happens if [()] is use in while loop
11th May 2020, 5:55 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
Yes right
11th May 2020, 5:59 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar