+ 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
18 Réponses
+ 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)
+ 3
Daniel Imanaliev ,
the code you have shown has a bug in line 1
+ 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.
+ 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.
+ 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.
+ 2
Lothar , Luo Shenshi , Jan , thanks a lot for your help and support! I really appreciate your assistance! 🙏
+ 2
Dave John ,
your post has been reported as spam because of the link in it.
+ 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...
+ 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.
+ 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 😊
+ 1
Lothar Yes, those two countdowns are just examples of what the output could be with different inputs.
+ 1
Daniel Imanaliev rakhmet bro!
+ 1
Daniel Imanaliev Your input is wrong, because you are missing a parenthesis.
It should look like this.....
number = int(input())
0
Счетчик number и ввод тоже number, поменяй имя переменной ввода. цикл while number не может не сравниваться с нулем поставь счётчик вместо нуля. А вообще лучше убери number =3. Зачем оно тебе? Если есть ввод.
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
0
number = int(input))
while number >= 0:
print(number)
number -= 1
0
Daniel Imanaliev, Dave John Thanks a lot!
0
maybe there's a syntax error, or maybe you forgot to add an indent? try copying .