Created
May 23, 2018 06:55
-
-
Save love-adela/792eebd67212a86321fb4c4f0c4b989d to your computer and use it in GitHub Desktop.
hacker_rank: time_conversion.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import os | |
import sys | |
# | |
# Complete the timeConversion function below. | |
# | |
def timeConversion(s): | |
ar = list(s) | |
del ar[2], ar[4] | |
time = ar[:6] | |
time = map(int, time) | |
ap = ar[6:] | |
print(ar, time, ap) | |
if ap[0] == "P": | |
time[0] += 1 | |
time[1] += 2 | |
del ap[0], ap[1] | |
ar = time | |
return ar | |
s = "07:05:45PM" | |
print(timeConversion(s)) | |
if __name__ == '__main__': | |
f = open(os.environ['OUTPUT_PATH'], 'w') | |
s = input() | |
result = timeConversion(s) | |
f.write(result + '\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment