Write a program to convert the time format from 12 hours to 24 hours. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
- 1

Write a program to convert the time format from 12 hours to 24 hours.

Write a Python program that will ask the user to input the time & will add one space after that (*like 1:15 PM*). And will convert the time fromm 12 hour format to 24 hour format. For example: Input: 1:15 PM Output: 13:15

20th Jul 2021, 6:05 AM
Ashutosh Pattnaik
Ashutosh Pattnaik - avatar
2 Respostas
+ 5
Hello, Ashutosh Pattnaik Show us your attempts! These questions are made for practice! Try it yourself, hints are also available at code coaches!
20th Jul 2021, 6:35 AM
Abhiyantā
Abhiyantā - avatar
+ 1
Ashutosh Pattnaik Using % with a bit of thought can help you with this problem. Break it down into smaller projects. You have a string input => 1:15 PM, but you need to break it into pieces & turn some of those pieces into integers. hrs mins am_pm If you are going to use math on hrs, then it needs to be an integer. if it is am or pm, then different math must apply. Remember => string output xx:xx Good luck.
20th Jul 2021, 10:12 AM
Rik Wittkopp
Rik Wittkopp - avatar