#1

Hello eveybody I am trying to do this exercise, but I do not understand why every time my code gives an error it does not asks for a new input:
Create function read hour ( NO input - parameters) As TRACK user Entering a Time With time , minutes and seconds quoted separately as quoted in example after . The function will ensure that the user Enters a proper time . The function should give an error for unchanged Incorrect user input and prompting the user To state time , minutes, or seconds again IF 's Not Correct . Function Should return a list with three items [ hour , minute, second ] .

and here is my code:

hour = -1
while hour<0 or hour>23:
hour = int(input("Enter hour: "))
if hour<0 or hour>23:
print("- ERROR: Hour must be between 0 and 23!")
minute = -1
while minute<0 or minute>59:
minute = int(input("Enter minute: "))
if minute<0 or minute>59:
print("- ERROR: Minute must be between 0 and 59!")
sec = -1
while sec<0 or sec>59:
sec = int(input("Enter second: "))
if sec<0 or sec>59:
print("- ERROR: Second must be between 0 and 59!")
return [hour,minute,sec]

``Replace this line with your code.``

#2

``````def readTime():
hour = -1
while hour<0 or hour>23:
hour = int(input("Enter hour: "))
if hour<0 or hour>23:
print("- ERROR: Hour must be between 0 and 23!")
minute = -1
while minute<0 or minute>59:
minute = int(input("Enter minute: "))
if minute<0 or minute>59:
print("- ERROR: Minute must be between 0 and 59!")
sec = -1
while sec<0 or sec>59:
sec = int(input("Enter second: "))
if sec<0 or sec>59:
print("- ERROR: Second must be between 0 and 59!")
return [hour,minute,sec]