'rock paper scissors lizrd spock game issue?
When I run my program my inputs do not print at all so I cannot enter my choice for the game.(Python) There are no syntax error or anything from what I can see but I still cannot input which moves I want to enter. I have defined player1 and player2 and have issued the correct parameters but nothing seems to be printing or being able to be input
while 1 == 1:
print("\n1.ROCK 2.PAPER 3.SCISSORS 4.LIZARD 5.SPOCK 6.EXIT")
player1 = int(input("\nEnter Player1's move (1-6): "))
if player1 == 6:
print("Player1 has left the game")
break
player2 = int(input("Enter Player2's move (1-6)"))
if player2 == 6:
print("Player2 has left the game")
break
move = ("ROCK", "PAPER", "SCISSORS", "LIZARD", "SPOCK")
victor = winner(player1, player2)
if victor == 1:
print(move[player1-1], "beats ", move[player2-1], ": PLAYER1 WON")
elif victor == 2:
print(move[player2-1], "beats", move[player1-1], ": PLAYER2 WON")
else:
print("Same moves! :", move[player1-1], "and ", move[player2-1])
break
Solution 1:[1]
Currently, a part of your code is after the break for player 2, which means it doesn't run.
Remove one indent for this section:
move = ("ROCK", "PAPER", "SCISSORS", "LIZARD", "SPOCK")
victor = winner(player1, player2)
if victor == 1:
print(move[player1-1], "beats ", move[player2-1], ": PLAYER1 WON")
elif victor == 2:
print(move[player2-1], "beats", move[player1-1], ": PLAYER2 WON")
else:
print("Same moves! :", move[player1-1], "and ", move[player2-1])
break
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DapperDuck |
