0

24 hrs to 12 hrs in phyton

Want to convert the given time in hours from 24 hrs to a time in hour for 12 hour clock

25th Sep 2018, 4:55 PM
ricardo
6 Respuestas
+ 6
If greater than one, you use "pm".
25th Sep 2018, 5:21 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
if you divide current time by 12 and the output is greater than 1, you have pm else am, then you only have to print the modulo of currTime % 12 and am/pm.
25th Sep 2018, 5:02 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 1
You can't use return outside of a function. Also it's probably easier to just check if hour > 12 than if hour % 12 > 1
26th Sep 2018, 6:28 AM
Anna
Anna - avatar
0
what if greater than 1
25th Sep 2018, 5:20 PM
ricardo
0
i want to return tge time but on 12 hour clock https://code.sololearn.com/cgG9oOXRyw8Q/?ref=app
25th Sep 2018, 5:35 PM
ricardo
0
the code is wrong
25th Sep 2018, 5:35 PM
ricardo