Converting a normal (12-hour) time like "8:30 am" or "8:30 pm" to 24-hour time (like "0830" or "2030") sounds easy enough, right?  Well, let's see if you can do it!
You will have to define a function named "to24hourtime", and you will be given an hour (always in the range of 1 to 12, inclusive), a minute (always in the range of 0 to 59, inclusive), and a period (either "am" or "pm") as input.
Your task is to return a four-digit string that encodes that time in 24-hour time.
def to24hourtime(hour, minute, period):
    hour_str = str(hour)
    minute_str = str(minute)

    if period == 'am':
        if hour <= 9:
            hour_str = '0' + hour_str
        if minute <= 9:
            minute_str = '0' + minute_str
        if hour == 12:
            hour_str = '00'

        return '%s%s' % (hour_str, minute_str)
    else:
        if hour <= 12:
            hour += 12
        if hour == 24:
            hour = 0
        hour_str = str(hour)
        
        if hour <= 9:
            hour_str = '0' + hour_str
        if minute <= 9:
            minute_str = '0' + minute_str
        if hour == 0:
            hour_str = '12'

        return '%s%s' % (hour_str, minute_str)

def to24hourtime(hour, minute, period):
    hour_str = str(hour)
    minute_str = str(minute)

    if period == 'am':
        if hour <= 9:
            hour_str = '0' + hour_str
        if minute <= 9:
            minute_str = '0' + minute_str
        if hour == 12:
            hour_str = '00'

        return '%s%s' % (hour_str, minute_str)
    else:
        if hour <= 12:
            hour += 12
        if hour == 24:
            hour = 0
        hour_str = str(hour)
        
        if hour <= 9:
            hour_str = '0' + hour_str
        if minute <= 9:
            minute_str = '0' + minute_str
        if hour == 0:
            hour_str = '12'

        return '%s%s' % (hour_str, minute_str)
