Skip to content

Commit fbe1e7f

Browse files
Time Conversion
Time Conversion
1 parent c6b47b0 commit fbe1e7f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Time Conversion

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/python3
2+
3+
import os
4+
import sys
5+
6+
#
7+
# Complete the timeConversion function below.
8+
#
9+
def timeConversion(s):
10+
#
11+
# Write your code here.
12+
#
13+
list1=['01','02','03','04','05','06','07','08','09','10','11','12']
14+
d={'01':'13','02':'14','03':'15','04':'16','05':'17','06':'18','07':'19','08':'20','09':'21','10':'22','11':'23','12':'12'}
15+
#print(list1)
16+
#print(d)
17+
18+
if s[8:]== "AM" and s[0:2] != "12" :
19+
return(s[:8])
20+
elif s[8:]== "AM" and s[0:2] == "12" :
21+
return("00"+s[2:8])
22+
23+
elif s[8:]== "PM":
24+
for i in range(0,12):
25+
if list1[i]== s[:2]:
26+
p=list1[i]
27+
return(d[p]+s[2:8])
28+
if __name__ == '__main__':
29+
f = open(os.environ['OUTPUT_PATH'], 'w')
30+
31+
s = input()
32+
33+
result = timeConversion(s)
34+
35+
f.write(result + '\n')
36+
37+
f.close()

0 commit comments

Comments
 (0)