+ 1

How to program a time converter

I can't seem to find the problem with my code because am still new in programming. So please I need some assistance

3rd Mar 2022, 4:12 PM
NKWAIN BLAISE NGAM
NKWAIN BLAISE NGAM - avatar
3 Respostas
+ 5
import datetime def timeconvert(str1): if str1[-2:] == "AM" and str1[:2] == "12": return "00" + str1[2:-2] elif str1[-2:] == "AM": return str1[:-2] elif str1[-2:] == "PM" and str1[:2] == "12": return str1[:-2] else: return str(int(str1[:2]) + 12) + str1[2:8] dt=datetime.datetime.now() print("Conversion Of Time ::",timeconvert(dt.strftime("%H:%M:%S")))
4th Mar 2022, 4:55 AM
Vaibhav
Vaibhav - avatar
+ 2
Let me try to find the problem with your code. Share it here(save it on the code playground and share it's link), even if i can't find it, others might
3rd Mar 2022, 4:14 PM
Rishi
Rishi - avatar
+ 1
Vaibhav Singh don't post the answer without any explanation
4th Mar 2022, 5:31 AM
Rishi
Rishi - avatar