>> I'm only stuck at one point: How do I loop back to the beginning in
>> case the user input is invalid?
>
>
> Look at Peter's example. He set a variable to false when the input was
> wrong. You can check that value in your while loop.

Ok, got you!

print("TIME TRACKING")

while True:
    hours_worked = input("How many hours did you work today? ")
    try:
        hours_worked = float(hours_worked)
        break
    except ValueError:
        print ("Invalid input")
if hours_worked < 24:
    print("You must be a human.")
else:
    print("You must be a cyborg.")

Program works well now, a learned a lot along the way.
Thank you & have a great weekend,

Raf
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to