# channel.py
# Program to simulate a *fancy* TV

def getbutton ():
# function to return the next button input by user;
# does error checking as well

    newbutton = input ()
    while newbutton != 'u' and newbutton != 'd' and newbutton != 'o':
        newbutton = input()
        
    return newbutton

def nextch (button, oldchannel):
# function to find and return the next channel
# button = button pressed by user
# oldchannel = previous channel

    if button == 'u':
        if oldchannel == 13:
            return 2
        else:
            return oldchannel + 1    
    elif oldchannel == 2:
        return 13
    else:
        return oldchannel - 1
    
def main ():
    channel = 2    # start on GBH - educational channel!
    
    print (channel)
    
    button = getbutton()
    while button != 'o':
        channel = nextch (button, channel)
        print (channel)
        button = getbutton()
main()
    
