-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime Conversion
More file actions
37 lines (29 loc) · 832 Bytes
/
Time Conversion
File metadata and controls
37 lines (29 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/python3
import os
import sys
#
# Complete the timeConversion function below.
#
def timeConversion(s):
#
# Write your code here.
#
list1=['01','02','03','04','05','06','07','08','09','10','11','12']
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'}
#print(list1)
#print(d)
if s[8:]== "AM" and s[0:2] != "12" :
return(s[:8])
elif s[8:]== "AM" and s[0:2] == "12" :
return("00"+s[2:8])
elif s[8:]== "PM":
for i in range(0,12):
if list1[i]== s[:2]:
p=list1[i]
return(d[p]+s[2:8])
if __name__ == '__main__':
f = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = timeConversion(s)
f.write(result + '\n')
f.close()