0

Solved! :"Need help! About "Introduction to Python" course, "Control Flow" Issue, Practice "Time's up""

Hi! Nice space for asking and solve doubts! Just needing help with the course of "Introduction to Python", in the issue of "Control Flow", the practice named "Time's up". Exercise: Create a time program that will take the number of seconds as input, and countdown to zero. It's the issue of loops and in this case it is needed the while loop. My answer was this one: " number = int(input()) while number > 0: number = number - 1 print(number) " Just don't know where's the mistake. Can anybody help me? What do you think about my answer? I think It's correct but the app says there's something wrong. I asked the IA assistant and solved the problem in the same way I did. But the app not because of that allowed me to continue with the other exercises. May be is something wrong, don't know what to think. Thanks for your time, wish someone can help me with this. Greetings and have nice programming study time! Correct solution: number = int(input()) while number >=0 print(number) number = number - 1

8th Feb 2024, 8:49 AM
Marina
4 Réponses
+ 2
Your code didn't include the zero itself in the output and they need it so simply reorder the line: Print(number) To be before the line: number = number - 1
8th Feb 2024, 9:14 AM
Andrew
+ 2
You can view the expected output from the "RESULT" tab. Tapping on the test case, and you will find what is the difference. Syntax wise there is nothing wrong, only the output is not the same as expected.
8th Feb 2024, 9:16 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Thank you very much Andrew! Greetings!
8th Feb 2024, 9:17 AM
Marina
+ 1
Thank you for your answer Wong Hei Ming! If you are interested the correct answer is what Andrew said! I checked it on the app! I put the correct solution at the final of the first text where I was asking help. Nice space! I'm new here! Greetings!
8th Feb 2024, 9:31 AM
Marina