def parse():
    """Parses the user input, starting with the number of blocks"""
    # Get the number of blocks
    while 1:
        num = sys.stdin.readline()
        try:
            num = int(num[:-1])
        except Exception, e:
            if num.lower() == 'quit\n': return
            else: continue
        else: break
    # Create the objects
    stacks = Stacks(num)
    arm = Arm(stacks)
    # Now parse each line of input ignoring dumb commands
    while 1:
        line = sys.stdin.readline().lower()[:-1] # Remove the enter at the end and convert to lowercase
        if line == 'quit':
            arm.quit()
            break
        else:
            words = line.split()
            if len(words) != 4: continue
            if words[0] not in ('move', 'pile'): continue
            try:
                a = int(words[1])
                b = int(words[3])
            except:
                continue
            if words[2] not in ('onto', 'over'): continue
            command = words[0] + words[2].capitalize()
            func = getattr(arm, command)
            func(a,b)
Parses the user input, starting with the number of blocks
recipes/Python/361168_Vpython_example/recipe-361168.py