+ 2

What is wrong with my cod? I couldn't pass lesson in Python introduction course.

# Принимаем число в качестве ввода number = int(input()) number =3 # Используем цикл while для обратного отсчета while number >=0: print(number) number -=1 # Конец цикла number =5 while number >=0: print(number) number -=1

3rd Nov 2024, 2:18 PM
Andrey Kan
18 Answers
+ 3
Andrey Kan , i can not find this exercise in the `introduction to python` tutorial. but it looks that this execise should produce a `countdown` from a given number (from the input) to 1? or 0?. this is *your* code, but without all non-essential code parts: number = int(input()) while number >=0: print(number) number -=1 > so it would be great if we could get a precise task description. > can you please check the conditional in the header of the while loop: should the countdown run until 0 or until 1? (currently it runs until 0)
3rd Nov 2024, 4:20 PM
Lothar
Lothar - avatar
+ 3
Daniel Imanaliev , the code you have shown has a bug in line 1
8th Nov 2024, 11:55 AM
Lothar
Lothar - avatar
+ 2
Lothar The exercise is only available for users with pro membership, that's why you can't find it. I found it, and the code snippet with the number input in your comment is correct.
3rd Nov 2024, 5:01 PM
Jan
Jan - avatar
+ 2
Jan , i suppose that you (as a pro member) can see the task description. Andrey Kan is talking about 2 countdowns that has to be done. maybe there are 2 samples that are shown, but i believe that only one input for a number has to be done, and one code that uses the various inputs. can you confirm this? anything else does not make much sence.
3rd Nov 2024, 6:59 PM
Lothar
Lothar - avatar
+ 2
Jan , thanks a lot! Andrey Kan , so now it should be possible to solve the task with one input procedure, and with one following code to output numbers from N (input number) to 0.
3rd Nov 2024, 7:15 PM
Lothar
Lothar - avatar
+ 2
Lothar , Luo Shenshi , Jan , thanks a lot for your help and support! I really appreciate your assistance! 🙏
4th Nov 2024, 4:00 AM
Andrey Kan
+ 2
Dave John , your post has been reported as spam because of the link in it.
8th Nov 2024, 11:50 AM
Lothar
Lothar - avatar
+ 1
Can you explain further more.. like what exactly are you trying to do, cuz you've used "number" 3 times as variable and idk how am I supposed to help...
3rd Nov 2024, 3:31 PM
Luo Shenshi
Luo Shenshi - avatar
+ 1
Sorry guys. The task is: Create a timer program that will take the number of seconds as input, and countdown to 0. There are two countdowns should be created from 3 to 0 and then as separate another one from 5 to 0.
3rd Nov 2024, 4:52 PM
Andrey Kan
+ 1
# Take input from the user for the initial countdown number = int(input("Enter the number of seconds to countdown from: ")) # Countdown from the user input to 0 while number >= 0: print(number) number -= 1 # Countdown from 3 to 0 number = 3 while number >= 0: print(number) number -= 1 # Countdown from 5 to 0 number = 5 while number >= 0: print(number) number -= 1 should be working now 😊
3rd Nov 2024, 5:00 PM
Luo Shenshi
Luo Shenshi - avatar
+ 1
Lothar Yes, those two countdowns are just examples of what the output could be with different inputs.
3rd Nov 2024, 7:13 PM
Jan
Jan - avatar
+ 1
Daniel Imanaliev rakhmet bro!
5th Nov 2024, 12:28 PM
Andrey Kan
+ 1
Daniel Imanaliev Your input is wrong, because you are missing a parenthesis. It should look like this..... number = int(input())
8th Nov 2024, 5:52 PM
Jan
Jan - avatar
0
Счетчик number и ввод тоже number, поменяй имя переменной ввода. цикл while number не может не сравниваться с нулем поставь счётчик вместо нуля. А вообще лучше убери number =3. Зачем оно тебе? Если есть ввод.
5th Nov 2024, 5:13 AM
Daniel Imanaliev
Daniel Imanaliev - avatar
0
# First countdown from 3 number = 3 while number >= 0: print(number) number -= 1 print() # Separator for clarity # Second countdown from 5 number = 5 while number >= 0: print(number) number -= 1 This is the right code for the above given code. If you want the book writing services you can visit this site: https://majesticghostwriting.com
8th Nov 2024, 12:48 AM
Dave John
Dave John - avatar
0
number = int(input)) while number >= 0: print(number) number -= 1
8th Nov 2024, 1:10 AM
Daniel Imanaliev
Daniel Imanaliev - avatar
0
8th Nov 2024, 3:58 AM
Andrey Kan
0
maybe there's a syntax error, or maybe you forgot to add an indent? try copying .
8th Nov 2024, 3:07 PM
Daniel Imanaliev
Daniel Imanaliev - avatar