+ 16
[ASSIGNMENT] 24 hours to 12 hours format.
Given a String in hh:mm:ss 24 hours format,write a program to convert the time to 12 hours format followed by 'AM' or 'PM'. For e.g: If input is '22:47:00' The output should be '10:47:00 PM' If input is '02:35:36' The output should be '02:35:36 AM'
27 Answers
+ 12
+ 8
https://code.sololearn.com/cLvA8OtK5SKF/?ref=app
+ 7
Ace I submit the challenges in Lesson Factory so they can be made assignments.But till they get approved as assignment I post them as challenges.
+ 5
//One liner function
https://code.sololearn.com/cT5NN43BLIFh/?ref=app
+ 5
Käzî Mrîdùl Høssäîn The code is awesome.
Thanks for taking part.
+ 5
Coder++ Its perfect now.👍👍
+ 4
mitali jadhavrao..
welcome
+ 3
You can use the following test cases to see if your code works for all conditions:
When input is "00:23:45"the output should be "12:23:45AM".
When input is "12:34:45" the output should be "12:34:45PM".
When input is"21:12:15" the output should be "09:12:15PM".
When input is "07:11:45"the output should be "07:11:45AM".
+ 3
thank you mitali
+ 3
My try with python:
https://code.sololearn.com/cdU1wTd1J7iu/?ref=app
+ 2
https://code.sololearn.com/c0UzTemxKzL3/?ref=app
https://code.sololearn.com/w532TLF1dibT/?ref=app
+ 2
D Janapriya Good code.👍
Although it would be great if we could give input as hh:mm:ss.
+ 2
@mitali jadhavrao I make some changes please check if it works correctly
+ 1
Coder++ when input is 12:34:45 ...the output should be 12:34:45pm
Also when input is 00:12:34
the output should be 12:12:34am
Please check for this cases.
+ 1
~ swim ~ No it should be 22:03:23
+ 1
~ swim ~ Good try.
It passed all the cases I was lookin for.
+ 1
Paul Jacobs Its perfect.👍
Thanks for participating.