+ 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
9 Antworten
+ 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
+ 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
+ 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