[solved] stuck in python time's up | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

17th Aug 2023, 12:58 AM
ruto bf
ruto bf - avatar
15 Answers
+ 11
ruto bf What you are looking for is a combination of > and ==, which is >=, the 'greater than or equal to' comparison operator.
17th Aug 2023, 1:06 AM
Mozzy
Mozzy - avatar
+ 6
you should use " >= " to include Zero .
18th Aug 2023, 12:02 PM
Benyamina Youcef
Benyamina Youcef - avatar
+ 3
Mozzy ty!!!
17th Aug 2023, 1:11 AM
ruto bf
ruto bf - avatar
+ 3
One more available solution is using -1 instead of zero.
18th Aug 2023, 5:20 PM
Citroen Picassa
Citroen Picassa - avatar
+ 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^
6th Nov 2023, 3:30 AM
Minhaj Zaidi
Minhaj Zaidi - avatar
+ 2
It is not working. Is there a bug in the app, it says try again something went wrong...
22nd Sep 2023, 7:47 AM
Muhammad Iqbal Dar
Muhammad Iqbal Dar - avatar
+ 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 👌
23rd Sep 2023, 5:36 PM
Kelvin Ronoh
Kelvin Ronoh - avatar
+ 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 .
9th Nov 2023, 9:00 PM
Thabo Egon
Thabo Egon - avatar
+ 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
28th Nov 2023, 7:06 AM
Wesley Gray
Wesley Gray - avatar
0
The count down is from 5 so 0 must be less
17th Aug 2023, 5:30 PM
George Ndungu
George Ndungu - avatar
0
تطبيق رائعсырппнррн
18th Aug 2023, 6:46 PM
Мирон
Мирон - avatar
0
I'm getting something went wrong with this code number = int(input()) While number >= 0: print(number) number = number - 1
30th Oct 2023, 9:11 PM
Thabo Egon
Thabo Egon - avatar
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)
9th Dec 2023, 6:12 PM
Mohammad Soltanpour
Mohammad Soltanpour - avatar
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 🤷🏼‍♂️ 😅😅😅
4th Jan 2024, 10:30 AM
Corvid Crane
Corvid Crane - avatar
0
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? :)
12th Mar 2024, 10:23 AM
Anna
Anna - avatar