Dylan Jackson
Dylan Jackson

Reputation: 31

Trying to get my code to update a players score in noughts and crosses if the two players were to draw

essentially I've tried a couple of things but it either prints, the players score with no updated score or Condradultions message with the draw message and updated scores. So not sure how to get it to Print the draw message and updated scores separately with the congratulations score. If more info is needed let me know. Thank you

    if GameHasBeenWon:  # Update scores and display result
        if (PlayerOneSymbol == CurrentSymbol):
            print(PlayerOneName + " congratulations you win!")
            PlayerOneScore += 1
        elif print(PlayerTwoName + " congratulations you win!"):
            PlayerTwoScore += 1
        else:
            print("A draw this time!")
            PlayerOneScore += float(0.5)
            PlayerTwoScore += float(0.5)

    print("\n")
    print(PlayerOneName + ", your score is: " + str(PlayerOneScore))
    print(PlayerTwoName + ", your score is: " + str(PlayerTwoScore))
    print();

Upvotes: 0

Views: 56

Answers (1)

Mark
Mark

Reputation: 563

You have print statement as condition:

elif print(PlayerTwoName + " congratulations you win!"):
    ...

print returns None, thats why this block of code will never execute.

I guess the correct condition would be

if PlayerTwoSymbol == CurrentSymbol:
    print(PlayerTwoName + " congratulations you win!")
    PlayerTwoScore += 1
...

Upvotes: 2

Related Questions