0
def timeConversion(s):
z = s.split(':')
if 'p' in z[2]:
    print("Hello")
    z[0] = str(int(z[0]) + 12)
    z[2] = z[2][:-2]
    t = (':'.join(str(i) for i in z))
    return(t)
if 'a' in z[2]:
    z[2] = z[2][:-2]
    t = (':'.join(str(i) for i in z))
    return(t)

if name == 'main': d = timeConversion('07:05:45PM') print(d)

2
  • expected output = 19:05:45 got None Commented Jan 28, 2019 at 5:20
  • There is at least one answer to the real question below, but maybe you could just use docs.python.org/3/library/… with %I and %p? Commented Jan 28, 2019 at 5:34

1 Answer 1

1
def timeConversion(s):
    z = s.split(':')
    if 'P' in z[2]:
        print("Hello")
        z[0] = str(int(z[0]) + 12)
        z[2] = z[2][:-2]
        t = (':'.join(str(i) for i in z))
        return(t)
    if 'A' in z[2]:
        z[2] = z[2][:-2]
        t = (':'.join(str(i) for i in z))
        return(t)
if __name__ == "__main__": 
    d = timeConversion('07:05:45PM') 
    print(d)
Sign up to request clarification or add additional context in comments.

1 Comment

'P' and 'A' are in uppercase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.