0
i = 5 while True: print(i) i = i - 1 if i<=2: 'break'
time limit exceed
10 Answers
+ 3
how did you do it
+ 3
You can use the code Wolf wrote. It is more efficient. But if you wanted to fix your code with the break statement, firstly know that break is not between quotes. Next, indentations are a very big deal in Python. The code in your question itself puts the if statement out of the loop because it has no indentation so keep that in mind.
Here is your code fixed
https://code.sololearn.com/cmto9q3RpQ8j/?ref=app
+ 2
i=5
while i >= 2:
print(I)
i -= 1
+ 2
âș I hear that Wolf. That is why I made it clear that your code was more efficient
+ 2
:3 it is only logical tho, more compact but still get the same result, that's what I try to teach
+ 2
anser 3
+ 1
well, u declare that var, then the statement should be for only while the I is more than two, instead of using a break statement
+ 1
make sure the vars are all the same, but other than that, it is correct
+ 1
That is Tru, but I try to guide people by the zen of Python, so I try for smaller, but with the same result
0
still the same thing showing at the output