1 回答

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊
game= input("Are you ready to ply? Y or N: ").capitalize()
user1 = input("What's your name? ")
user2 = input("What's your name? ")
p1_count=0
p2_count=0
games_played = 0
while game == "Y":
p1 = input(user1 + ": Rock, Paper, Scissors? ").lower()
p2 = input(user2 + ": Rock, Paper, Scissors? ").lower()
if p1 == "rock":
if p2 == "rock":
print("It\'s a tie!")
game = input("Are you ready to ply? Y or N: ").capitalize()
p1_count += 1
p2_count += 1
games_played += 1
elif p2 == "scissors":
print(user2 + ", you got beat mothafucka!")
game = input("Are you ready to play? Y or N: ").capitalize()
p1_count += 1
games_played += 1
elif p2 == "paper":
print(user1 + ", you got beat mothafucka!")
game = input("Are you ready to play? Y or N: ").capitalize()
p2_count += 1
games_played += 1
elif p1 == "scissors":
if p2 == "scissors":
print("It\'s a tie!")
game = input("Are you ready to play? Y or N: ").capitalize()
p1_count += 1
p2_count += 1
games_played += 1
elif p2 == "paper":
print(user2 + ", you got beat mothafucka!")
game = input("Are you ready to play? Y or N: ").capitalize()
p1_count += 1
games_played += 1
elif p2 == "rock":
print(user1 + ", you got beat mothafucka!")
game = input("Are you ready to play? Y or N: ").capitalize()
p2_count += 1
games_played += 1
elif p1 == "paper":
if p2 == "paper":
print("It\'s a tie!")
game = input("Are you ready to ply? Y or N: ").capitalize()
p1_count += 1
games_played += 1
elif p2 == "rock":
print(user2 + ", you got beat mothafucka!")
game = input("Are you ready to ply? Y or N: ").capitalize()
p1_count += 1
games_played += 1
elif p2 == "scissors":
print(user1 + ", you got beat mothafucka!")
game = input("Are you ready to ply? Y or N: ").capitalize()
p2_count += 1
games_played += 1
print("Thank you " + user1 + " and " + user2 + " for playing this classic fucking game!")
print("With " + str(games_played) + " games played, " + "the score was " + user1 + " with " + str(p1_count) + " and " + user2 + " with " + str(p2_count))
只需將這兩行 ( p1 and p2) 放入while循環(huán)中,就完成了!
這里發(fā)生的事情是,您沒(méi)有為下一次執(zhí)行while循環(huán)獲取輸入。所以值p1和p2保持不變。
所以,這現(xiàn)在可以工作了,更正了一些錯(cuò)誤..(elif第二條和第三條elif語(yǔ)句中的最后一條語(yǔ)句)
添加回答
舉報(bào)