0
Python Practice: Time is up
Hello, can someone please explain me some code fragment. In python for beginners we learn that the “while loop” is without “=“ In the practice “time is up” we should create a countdown. Code looks like this: # take the number as input number = int(input()) #use a while loop for the countdown while number>= 0: print(number) number = number -1 Why is in the line with the while function an “=“ sign because we learned the loop whiteout it but the code doesn’t work without it. Thanks in advance
3 ответов
+ 2
if you dont want the equal sign you could do
while number > -1
+ 1
while number>=0 stops at 0
while number >0 stops at 1
number = number-1 can be rewritten as:
number -= 1
+ 1
I now i understand why and how to go around the equal sign, i was just confused because it wasnt explained like this in the tutorial before.
Thank you so much both of you