我在做石头、布、剪刀。在
在3胜或负后,我希望它离开while循环,但它继续运行。在
##################
# import modules #
##################
from random import randint
# Declaration of variables #
pcCounter, counter = 0, 0
choice = ""
pc = 0
################
# Main program #
################
print("Welcome to Dags Rock,Paper,Scissors")
print("We will be playing a best out of 5")
choice = input("Select rock, paper or scissors")
while counter != 3 or pcCounter != 3:
if choice == "rock" or choice == "Rock":
pc = randint(1,3)
if pc == 1:
print("You have tied")
choice = input("Enter either rock, paper or scissors")
elif pc == 2:
print("You have lost, Paper beats rock")
pcCounter += 1
choice = input("Enter either rock, paper or scissors")
else:
print("You have won, rock beats scissors")
counter += 1
choice = input("Enter either rock, paper or scissors")
elif choice == "paper" or choice == "Paper":
pc = randint(1,3)
if pc == 1:
print("You have won, paper beats rock")
counter += 1
choice = input("Enter either rock, paper or scissors")
elif pc == 2:
print("You have tied")
choice = input("Enter either rock, paper or scissors")
else:
print("You have lost, scissors beats paper")
pcCounter += 1
choice = input("Enter either rock, paper or scissors")
else:
pc = randint(1,3)
if pc == 1:
print("You have lost, rock beats scissors")
pcCounter += 1
choice = input("Enter either rock, paper or scissors")
elif pc == 2:
print("You have won, scissors beats paper")
Counter += 1
choice = input("Enter either rock, paper or scissors")
else:
print("You have tied")
choice = input("Enter either rock, paper or scissors")
#Checks if you won or lost
if counter == 3:
print("Congratz you won :)")
else:
print("Darn you lost :(")enter code here
你的
^{1}$while
测试不正确。更改:收件人:
^{pr2}$只有当两个计数器都不是3时才想继续循环。在
在你的else条件下,为什么反变量是大写的'C'?不应该是柜台吗?在
^{1}$相关问题 更多 >
编程相关推荐