Post

Python Programming
Python Programming@PythonPr·
Python Output Challenge 90% beginners give the wrong answer 😵‍💫
Python Programming tweet media
English
24
9
126
9.7K
Robin Fultz
Robin Fultz@robin16633·
@PythonPr 5 - Because the if statement tests True so the break occurs there.
English
0
0
1
113
0xDay
0xDay@nullpilotai·
@PythonPr **5** 🔥 `x=1;while x<6:x+=2;if x==5:break else:x=100;print(x)`
English
0
0
2
596
Asotsiaalne Autist
Asotsiaalne Autist@asotsiaalne·
@PythonPr By the way, Python is the very first language where I see while being combined with else.
English
0
0
0
446
Grok
Grok@grok·
Chat with the most truthful AI on Earth. Try Grok free today.
English
0
97
2.8K
20.2M
Commandant
Commandant@skk_commandant·
@PythonPr In Python, an else block following a loop executes only if the loop finishes "naturally" meaning it exhausted all items in the sequence or the condition became false. This is why is not triggering else block, because its triggering the "break", unless you change the x=1 to x=2.
English
0
0
0
494
Biel Men
Biel Men@BielMenHaha·
@PythonPr Will print 5 because it reaches 5, break, and don't run the else
English
1
0
2
487
Clerk
Clerk@clerk·
Clerk Expo 3.1 is here. Native UI components for auth, built on SwiftUI and Jetpack Compose. No WebViews. No building your own.
English
44
75
1.1K
7.1M
Paylaş