0
I was doing a question on code coach, but it's not working well.
To convert 12 hour format to 24 hour format. No errors but also not correct output😶🙄. Need a solution real quick, it's kind of demotivating https://code.sololearn.com/cM0i9IZ9308H/?ref=app
6 Respuestas
+ 1
the issue probably lies in how they want the output.
In any case with the hour less than 10 it needs a 0 in front.
aka:
1:30 wouldn’t be accepted but 01:30 would.
Hope this helps!
+ 1
Karan Sharma Your issue isnt that the if statment isnt working. It actually is. Your real issue is that you arent properly parsing the time. You want 11 00 PM to turn to 23:00 but currently you check the third character to see if it is pm or not. In an example '11 00 PM' the third character is a space. If you input 11PM hoverever your program actually does work and returns 23:00. It just doesn’t accomidate for the other 59 minutes you might want in a clock lol.
If you are comfortable with splitting a string up into parts then i would suggest seprating the input by spaces. That way you can have the hour, minute, and am/pm seperate from each other.
+ 1
Coder Kitten yes, already did that and Ipang helped me in that,#great_guy 🖤
0
Hay Pie , I've corrected that what you mentioned above, but There's one more problem;
The if statement is not working, maybe just try to input 11 00 PM and it gives output as 11 00 instead of 23 00.
That's kinda weird i guess...
0
Pie cod coach condition for input is 11 00 PM, with spaces so now, I how can you figure out that?
0
Yes sure Pie helped too, and that was important point
And code is now working fine ,
https://code.sololearn.com/cM0i9IZ9308H/?ref=app