zackBYE344
zackBYE344

Reputation: 63

Why is My Program Skipping Two Else If Statement After Using Them Once

I am creating a program that continuously keeps track of round wins until the user enters "exit". For my error, when I put one win for either player the program works. When I put in more than one point, the program does say who has the most points. For example, I gave player 2 two round wins while I gave the player 1 one round win, the same issue happens vice versa. The program does not print who has the most round wins.

Here's my code:

points1 = 0
points2 = 0
total1 = 0
total2 = 0

player1 = input("Enter first player name: ")
player2 = input("Enter second player name: ")

while True:
    
    descision = int(input("***\n1-enter a new round winner\n2-check who has the most wins\n"))
    
    if descision == 1:
        
        player = input("Who has won this round?")
        
        if player == player1:
            total1 = points1 + 1
        elif player == player2:
            total2 = points2 + 1
    elif int(descision) == 2 and total1 == 0 and total2 == 0:
        print("No games played yet.")
    elif int(descision) == 2 or total1 != 0 or total2 != 0:
        if total1 > total2:
            print(player1 + " has the most wins so far.")
        elif total1 < total2:
            print(player2 + " has the most wins so far")
    elif str(descision) == "exit":
        break

Upvotes: 0

Views: 32

Answers (1)

schtalman
schtalman

Reputation: 202

in line 18 and 20 you should increase the total point, you always set the "total" to 1 just change it to

    total1 = total1 + 1
    total2 = total2 + 1

Upvotes: 1

Related Questions