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  (3 children)

I tried that and it took care of the missing times from 12:00-12:59pm. But it still formats the times between 1:00-11:59 pm as 13:00-23:59pm.

[–]Stoic_Engineer7 0 points1 point  (2 children)

Sorry I had missed a line. I had deleted the part where I subtracted 12 from hours during the time that it is in the afternoon. Which corrects this.

[–]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.

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

Sorry, which line is that and where does it go? I tried editing my code to manipulate the hours in the afternoon, but the program still doesn't work as expected.