+ 8
[solved] stuck in python time's up
it asks to create a program that countdowns the seconds til zero one of the expected outputs is 5, 4, 3, 2, 1, 0 i did this: number = int(input()) while number > 0: print (number) number = number - 1 but the zero wasn't included. should i use == instead of > ? or something else? i tried a lot of things but couldn't solve it and didn't get a hint either
17 Respostas
+ 13
ruto bf
What you are looking for is a combination of > and ==, which is >=, the 'greater than or equal to' comparison operator.
+ 6
you should use " >= " to include Zero .
+ 3
Mozzy ty!!!
+ 3
One more available solution is using -1 instead of zero.
+ 3
# take the number as input
number = int(input())
#use a while loop for the countdown
while number >=0:print(number);number = number - 1
This above is the right code^
+ 2
It is not working. Is there a bug in the app, it says try again something went wrong...
+ 1
Guys, i also stuck for a while 😄 but finally passed.
# take the number as input
number = int(input())
#use a while loop for the countdown
while number >= 0:
print(number)
number = number - 1
That's the correct form 👌
+ 1
Minhaj Zaidi the identation in the above code is wrong, leading to the countdown not running or the system reading a large code to run. The 3rd and 4th line identation is key to the code. Finally figured it out though. Thanks Thanks for the response .
+ 1
make sure that you are using proper indentation:
number = int(input())
while number >= 0:
print(number)
number = number -1
you can also write it like so:
while number >= 0:
print(number)
number -= 1
+ 1
number= int(Input())
while number >=0 :
print (number )
print ("\n")
number = number-1
I wanted to make a new line after every count. But it doesn't work. What's wrong in my code? :)
0
The count down is from 5 so 0 must be less
0
تطبيق رائعсырппнррн
0
I'm getting something went wrong with this code
number = int(input())
While number >= 0:
print(number)
number = number - 1
0
# Take the number as input
number = int(input())
# Use a while loop for the countdown
while number > 0:
print(number)
while number > 0:
number = number - 1
print(number)
0
I struggled with this for 30 minutes, until I came here and realized I was typing
while number>0:
Instead of
while number>=0:
Of course I had to have the = in order to count 0 itself 🤷🏼♂️
😅😅😅
0
number = int(input())
while number >= 0:
print(number)
number = number-1