Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Wincount for rock/paper/scissor game does not increase after a win. Additionally, how can I make it so the code continually runs games after eachother in python topic ?

By M.K. Verma · 3 May 2022

Wincount for rock/paper/scissor game does not increase after a win. Additionally, how can I make it so the code continually runs games after eachother in python topic ?

Try This 

print("Welcome to Rock | Paper | Scissors")
player1_wincount = 0
player2_wincount = 0
round = 1

x = input("Would you like to play a game?\n")
if x == "Yes" or "yes" or "YES" or "Yeah" or "yeah" or "Yup" or "yup" or "Yessir" or "yessir":
    a = 1 
    player1_name = input("Player 1, please enter your name:\n")
    # player1_age = input("Player 1, please enter your age:\n")
    player2_name = input("Player 2, please enter your name:\n")
    # player2_age = input("Player 2, please enter your age:\n")
else: 
    a = -1

while a > 0:
    print("Round", round)
    player1_selection = int(input("Player 1, please select from the following options:\n1:Rock\n2:Paper\n3:Scissors\n4:EXIT\n"))
    player2_selection = int(input("Player 2, please select from the following options:\n1:Rock\n2:Paper\n3:Scissors\n4:EXIT\n"))
    
    if player1_selection == 1 and player2_selection == 1:
        print("Tie!")
    elif player1_selection == 1 and player2_selection == 2:
        print("Player 2 Wins!")
        player2_wincount += 1
    elif player1_selection == 1 and player2_selection == 3:
        print("Player 1 Wins")
        player1_wincount += 1
    elif player1_selection == 2 and player2_selection == 1:
        print("Player 1 Wins!")
        player1_wincount += 1
    elif player1_selection == 2 and player2_selection == 2:
        print("Tie!")
    elif player1_selection == 2 and player2_selection == 3:
        print("Player 2 Wins!")
        player2_wincount += 1
    elif player1_selection == 3 and player2_selection == 1:
        print("Player 2 Wins!")
        player2_wincount += 1
    elif player1_selection == 3 and player2_selection == 2:
        print("Player 1 Wins!")
        player1_wincount += 1
    elif player1_selection == 3 and player2_selection == 3:
        print("Tie!")
    else:
        a = -1
        break
    round += 1 
    

print (player1_name,"has", player1_wincount, "wins!\n", player2_name, "has", player2_wincount, "wins!")