昨天我设法使这段代码起作用,但是当我今天去尝试时,它只是循环自身,我不知道为什么这样做。
这是代码:
global p1_final_score
global p2_final_score
global p1_round1_score
global p2_round1_score
print("player 1 turn")
player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE +
input( "Press 1 to roll dice: "))
#timer delay which pauses before continuing to next line
time.sleep(0.25)
while player1_dice1_round1_dice != "1":
player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE +
input( "Press 1 to roll dice: "))
time.sleep(0.25)
else:
player1_dice1_round1_answer = random.randint(1, 6)
time.sleep(0.25)
print("You rolled the first dice and the answer is: ",
player1_dice1_round1_answer)
time.sleep(0.25)
答案 0 :(得分:0)
更改
player1_dice1_round2_dice = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
到
player1_dice1_round2_dice = input(Fore.GREEN + "Round2/Player1: " + Fore.WHITE +"Press 2 to roll dice: ")
在所有代码中执行相同的操作。
ps:或者,ctrl + Z将还原所有更改。直到您处于运行状态为止。