0
what is wrong with this military time code.
i write this code using python and i am a beginner. please see the military time problem which is given by sololearn, i created this code. anyone please help me. code : x = int(input("Enter The Time: ")) y = input("enter AM or PM: ") if x >= 1 and y == AM: print(x) elif x >=1 and y == PM: print(x+12) else: print("please enter the right time!")
8 Respostas
+ 3
Ex: Input sample :
07:22 PM
You can read this into a single variable as a string. You have to convert this to required answer, that is 19:22
Varies ways you can. In your code, it can't convert to int directly...
Just take as input(), no text inside. If you extract 'AM' or 'PM' to y then, stil it is string so compare like y=='AM' or y=='PM'.
+ 2
Hint: AM/PM is the name of a object, not a String
+ 1
Single line, single string input:
"12:34 am" e.g.
0
The code coach will provide the input within a single line. You may not output an additional message when getting the output, because it will be printed and clutter your output. And you'll have to handle the 24:00 problem.
0
Sandra Meyer are you saying that i have to use only one input?
0
You want to convert the time from a 12 hour clock to a 24 hour clock. If you are given the time on a 12 hour clock, you should output the time as it would appear on a 24 hour clock.
Task:
Determine if the time you are given is AM or PM, then convert that value to the way that it would appear on a 24 hour clock.
Input Format:
A string that includes the time, then a space and the indicator for AM or PM.
Output Format:
A string that includes the time in a 24 hour format (XX:XX)
Sample Input:
1:15 PM
Sample Output:
13:15
0
Esch @esci i didn't understand bro.
please explain me