Skip to content

Instantly share code, notes, and snippets.

@love-adela
Created May 23, 2018 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save love-adela/792eebd67212a86321fb4c4f0c4b989d to your computer and use it in GitHub Desktop.
Save love-adela/792eebd67212a86321fb4c4f0c4b989d to your computer and use it in GitHub Desktop.
hacker_rank: time_conversion.py
#!/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