0

i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") print("Finished") break

why break is not working in last. even this 'break' is inside my while loop. comment/guide me with easy methods and using easy English words. thank you https://code.sololearn.com/cQ80u4LENN32/?ref=app

17th Dec 2017, 2:31 AM
Rohit Raj
Rohit Raj - avatar
10 Réponses
+ 5
Like Jamie said, it needs to be indented. Python uses indentations and whitespace whereas many programs ignore it but require more code. When you run your code it mentions it expects indentation.
17th Dec 2017, 3:39 AM
Duncan
Duncan - avatar
+ 4
@Pranit Bhoir the if statement will break the loop (after i==5) once it's indented so it won't be infinite.
17th Dec 2017, 3:42 AM
Duncan
Duncan - avatar
0
can you please elaborate
17th Dec 2017, 2:35 AM
Rohit Raj
Rohit Raj - avatar
0
@pranit bhoir . if I want to perform 4 tasks after any condition is true then? should I write same condition 4 times? please ans logically dude. don't throw random wrong information.
17th Dec 2017, 4:05 AM
Rohit Raj
Rohit Raj - avatar
0
thank you @jamie . I am Rohit bdw 😃
17th Dec 2017, 4:07 AM
Rohit Raj
Rohit Raj - avatar
0
please explain me : while 1==1: meaning of it in details
16th Nov 2020, 8:22 PM
Atul Singh
Atul Singh - avatar