コード例 #1
0
        for i in range(len(stacksLst)):
            name = stacksLst[i].get_name()
            letter = choices[i]
            print("Enter {letter} for {stack}".format(letter=letter,
                                                      stack=name))

        user_input = input("")
        if user_input in choices:
            for i in range(len(stacksLst)):
                if user_input == choices[i]:
                    return stacksLst[i]


numUserMoves = 0

while rightStack.get_size() != numDisks:
    print("\n\n\n...Current Stacks...")
    for i in stacksLst:
        i.print_items()

    while True:
        print("\nWhich stack do you want to move from?\n")
        fromStack = get_input()
        print("\nWhich stack do you want to move to?\n")
        toStack = get_input()

        if fromStack.is_empty():
            print("\n\nInvalid Move. Try again.")
        elif toStack.is_empty() or fromStack.peek() < toStack.peek():
            disk = fromStack.pop()
            toStack.push(disk)