Function definition | Sololearn: Learn to code for FREE!


Function definition

Write a function named convert_12_to_24 that will accept an integer hour, an integer minute, and a string that is either AM or PM to indicate whether the time is before or after noon. It should return a string indicating a 24 hour time with the hour and minute separated by a colon.

10/16/2019 6:28:12 PM

Mamadou Barry

5 Answers

New Answer


time="hh-mm-am/pm" //taking input(it will come in above format) hh=int(time [0:2]) mm=int(time[3:5]) am_pm=time[6:8] Now you have all information to solve this problem, use am_pm part to form different cases and solving it.


Taste stuck at the part where you do all the work 👍


which part you currently stuck at ?


im not sure hoe to begin


start by creating the function take 3 input to 3 different varables for hour, minute, and ampm. then think.. you you normally convert it into 24hour format. write them down in full detail.