+ 2
i = 3 while i >= 0: print(i) i = i - 1
time limit exceed
6 Réponses
+ 2
try:
i = 3
while i >= 0:
print(i)
i = i - 1
+ 2
In Python indentations are a very big deal since it does not support curly braces like Java does for instance.
So the way your code is: i = i - 1 is not inside what should be executed if the loop condition is true. And so it will result in an infinite loop and keep printing 3.
To fix, indent i = i - 1 as suggested by Aaron.
+ 2
sneeze I agree!
+ 1
Which language ? Please put the language you use in the tags.
+ 1
I am a c# specialist. I was missing some {}{} braces now I understand why. With the language in the tags you attract the python people