Skip to content

Commit 4d67752

Browse files
Add files via upload
converting 12 hr format to 24 hr format
1 parent 60a5af2 commit 4d67752

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

24 hr.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
def convert24(str1):
3+
4+
if str1[-2:] == "AM" and str1[:2] == "12":
5+
return "00" + str1[2:-2]
6+
7+
8+
elif str1[-2:] == "AM":
9+
return str1[:-2]
10+
elif str1[-2:] == "PM" and str1[:2] == "12":
11+
return str1[:-2]
12+
13+
else:
14+
15+
return str(int(str1[:2]) + 12) + str1[2:8]
16+
17+
18+
str1=input("enter time")
19+
print(convert24("str1"))

0 commit comments

Comments
 (0)