- 3

And what is the reason of this answer!

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

11th May 2020, 5:32 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
10 odpowiedzi
+ 2
Just saw, this is a duplicate question: https://www.sololearn.com/discuss/2288304/?ref=app
11th May 2020, 5:47 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 2
You put an empty tuple as a condition. They are false, so your loop doesn't run at all. Else directly after a loop means: If no break happened in the loop... Since this is the case, 2 is printed.
11th May 2020, 5:53 PM
HonFu
HonFu - avatar
0
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:43 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
For all collections (Strings, dicts, arrays, tuples, etc.) empty collections are considered as False, non-empty as True. Btw. an array with an empty tuple is not empty. https://code.sololearn.com/c93cK6be0wHp/?ref=app
11th May 2020, 5:59 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
((),) this confused me again🤔😟
11th May 2020, 6:11 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
Please describe in proper way and use all aspects
11th May 2020, 6:11 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
Dilyorbek Valijonov type @ and you will see the list of users in this thread and the ones you are related with.
11th May 2020, 6:15 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
Manu_1-9-8-5 please tell the answer
11th May 2020, 6:16 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
Consider that outer parentheses are "ignored". It does not matter how many you place around, if you do not provide values or commas to define other tuples (see also the answer regarding single element tuple by 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥) they are skipped. See example printing tuple length: https://code.sololearn.com/cgXBGFz0YO3W/?ref=app
11th May 2020, 6:33 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
- 1
Ans is 1 1 1 2 I think if i correct then like
11th May 2020, 5:46 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar