Skip to content

Instantly share code, notes, and snippets.

@tanayag
Created June 2, 2016 13:36
Show Gist options
  • Save tanayag/6ed6425ea0eebdeccf22182e4110901f to your computer and use it in GitHub Desktop.
Save tanayag/6ed6425ea0eebdeccf22182e4110901f to your computer and use it in GitHub Desktop.

Revisions

  1. tanayag created this gist Jun 2, 2016.
    34 changes: 34 additions & 0 deletions time_converter.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    time = raw_input('Enter Time(hh:mm:ssAM/PM): ')

    AP = time[8]


    if AP == 'A' and time[0:2] == '12':
    ms = time.strip('AM')
    p = '00'
    print p + ms[2:]

    elif AP == 'A':
    print time.strip('AM')


    elif AP == 'P' and time[0:2] == '12':
    print time.strip('PM')




    elif AP == 'P' and time[0:2] != '12':
    mt = time.strip('PM')

    x = mt[0:2]
    x = int(x)

    y = x + 12
    y = str(y)
    z = mt[2:]

    mt = y + z

    print mt