+ 2

i = 3 while i >= 0: print(i) i = i - 1

time limit exceed

16th Apr 2018, 5:49 PM
Elisha Miracle
Elisha Miracle - avatar
6 ответов
+ 2
try: i = 3 while i >= 0: print(i) i = i - 1
16th Apr 2018, 5:51 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 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.
16th Apr 2018, 6:03 PM
cyk
cyk - avatar
+ 2
sneeze I agree!
16th Apr 2018, 6:09 PM
cyk
cyk - avatar
+ 1
Which language ? Please put the language you use in the tags.
16th Apr 2018, 5:52 PM
sneeze
sneeze - avatar
+ 1
sneeze tags would be better, but isn't this obviously python?
16th Apr 2018, 5:55 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 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
16th Apr 2018, 6:06 PM
sneeze
sneeze - avatar