[Python] how do get my code to match? i feel close but im not sure [duplicate]

Discussão em 'Python' iniciado por Stack, Dezembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    def stick_game():
    num_sticks = 11
    player = 1
    playing = True

    print("***** WELCOME TO NIM! *****")
    print("Each player will take turns removing")
    print("1, 2, or 3 sticks from the initial 11.")
    print("The player who removes the last stick wins!")
    while playing:
    print(f"\nPlayer {player}, it's your turn!")
    print(f"Here are the sticks remaining: {'|' * num_sticks}")

    move = int(input("How many would you like to remove?"))

    while move < 1 or move > 3 or move > num_sticks:
    if move > num_sticks:
    print("Can not take more sticks than remain. Try again:")
    else:
    print("Invalid move. Try again:")
    move = int(input("Invalid move. Try again: "))


    num_sticks -= move

    if num_sticks == 0:
    print(f"Congratulations Player {player}, you win!")
    playing = False

    player = 2 if player == 1 else 1


    stick_game()


    your text i have to enter 4,0,3,3,3,3,2 i cant use break or while true, i guess its bad practice. this is my first term in python so if its obvious, just know im a scrub this is the error i get

    Continue reading...

Compartilhe esta Página