0
Military time challenge fail in this simple code how?
how this could fail if itâs work perfect on my pc I already tested with 12:00 AM, 12:00 PM, 12:00 am, 12:00 pm, 1:00 AM, 1:00 PM PLEASE tested your self time_normal = input() time_normal = time_normal.split() clock_time = time_normal[0].split(":") time_normal[1] = time_normal[1].upper() if time_normal[1] == "PM": if clock_time[0] != "12": clock_mili = int(clock_time[0]) + 12 clock_time[0] = str(clock_mili) else: if clock_time[0] == "12": clock_time[0] == "00" else: if int(clock_time[0]) < 10 and len(clock_time[0]) == 1: clock_time[0] == "0" + clock_time[0] output = clock_time[0] + ":" + clock_time[1] print(output)
8 Respostas
+ 2
Oliver Reyes you can use steing formating to write 00-12.
old syntax was print( "%02d:%02d" % (clock_time[0],clock_time[1]))
like in C++ . But now there is a new variant with using {} brackets instead of % sign in string formating
+ 1
It sholud output
12:00 AM to 00:00
1:00 AM to 01:00 (single digit 0 to 00, 9 to 09)
+ 1
Are you getting the those results..?
I tested it failing...
What you getting for 1:00 AM & 12:00 AM?
0
it does
0
got it: put double equal insted of = in the two else lines thatâs the reason in my computer does work
0
Yes. Also else part's case 12 code part, also sholud be added in 12 PM case in first if...
0
thankâs dude is my first lenguage
0
oliver reyes You're welcome... Happy learning..