如何在下面的代码中结束 while 循环?
How can I end the while loop in my code below?
我是 python 初学者。我写了一段代码,但它无法跳出循环。它不断提示用户进行选择。我希望它接受输入,然后继续 print()。
谁能告诉我输入后如何结束 while 循环?
import random
choices = ["Rock", "Scissors", "Paper"]
computer = random.choice(choices)
player = None
while player not in choices:
player = input("rock, scissors, or paper?").lower()
print("Computer: ",computer)
print("Player: ",player)
正确的代码是
import random
choices = ["Rock", "Scissors", "Paper"]
computer = random.choice(choices)
player = None
while player not in choices:
player = input("Rock, scissors, or paper?").capitalize()
print("Computer: ",computer)
print("Player: ",player)
我是 python 初学者。我写了一段代码,但它无法跳出循环。它不断提示用户进行选择。我希望它接受输入,然后继续 print()。 谁能告诉我输入后如何结束 while 循环?
import random
choices = ["Rock", "Scissors", "Paper"]
computer = random.choice(choices)
player = None
while player not in choices:
player = input("rock, scissors, or paper?").lower()
print("Computer: ",computer)
print("Player: ",player)
正确的代码是
import random
choices = ["Rock", "Scissors", "Paper"]
computer = random.choice(choices)
player = None
while player not in choices:
player = input("Rock, scissors, or paper?").capitalize()
print("Computer: ",computer)
print("Player: ",player)