私はpython(とそのことについてはコーディング)には新しく、ロック、ペーパー、はさみの運動を行っています。 2番目のゲームの後で、私のコードは私が別のものをプレイしたいのであれば私に尋ねるのではなく、自動的にゲームの関数を呼び出します。誰かが私が間違って行くことができるか知っていますか?あなただけ依頼する必要がありロック、ペーパー、はさみのゲームは意図したとおりにループしません
import sys
print("Welcome to rock, paper, scissors!")
player_a = input("Player A input one of the following; rock, paper or scissors: ")
player_b = input("Player B input one of the following; rock, paper or scissors: ")
def game(p1, p2):
if p1 == p2:
print("It is a draw!")
elif p1 == "rock" and p2 == "scissors":
print("Player A wins!")
elif p1 == "rock" and p2 == "paper":
print("Player B wins!")
elif p1 == "paper" and p2 == "rock":
print("Player A wins!")
elif p1 == "paper" and p2 == "scissors":
print("Player B wins!")
elif p1 == "scissors" and p2 == "rock":
print("Player A wins!")
elif p1 == "scissors" and p2 == "paper":
print("Player B wins!")
game(player_a, player_b)
playAgain = input("Would you like to play again? (Insert Y or N): ")
while playAgain == "Y":
player_a = input("Player A input one of the following; rock, paper or scissors: ")
player_b = input("Player B input one of the following; rock, paper or scissors: ")
game(player_a, player_b)
else:
print("Thanks for playing!")
sys.exit()
「あなたはもう一度やりたいですか?」と尋ねるビットはループ内にないので、一度だけ実行されます。 – khelwood