Skip to content

Instantly share code, notes, and snippets.

@Verurteilt
Created Jul 13, 2013
Embed
What would you like to do?
Topic 3 Q 9 Pyschools
def time24hr(tstr):
x=tstr[-2:]
y=tstr.split(':')
z=y[0]
global v
v=y[1]
global b
global c
global total
if x== "am":
b=v.split("a")
c=b[0]
else:
b=v.split("p")
c1=b[0]
if x == "am" and z != "12":
total="%s%shr"%(z,c)
elif x == "am" and z == "12":
z="00"
total="%s%shr"%(z,c)
elif x == "pm" and z != "12":
z=int(z)
z=z+12
total="%s%shr"%(z,c1)
elif x == "pm" and z == "12":
total="%s%shr"%(z,c1)
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment