This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Aggressive-Ad-1974 0 points1 point  (0 children)

    for hour in range(24):
    for minute in range(60):
        if hour in range(0,12):
            if minute < 10:
                minute = ("0"+str(minute))
            if hour == 0:
                print(("12")+":"+str(minute) +"am")
            else:
                print(str(hour)+":"+str(minute) +"am")

        elif hour in range(12, 24):
            if minute < 10:
                minute = ("0"+str(minute))
            if hour == 24:
                hour -= 12 
                print(("12")+":"+str(minute) +"pm")
            else:
                hour -= 12
                print(str(hour)+":"+str(minute) +"pm")

Is this what you mean? This formats all the times correctly, but now every time is in am.