昨天这有效,但今天却没有

时间:2019-02-28 15:49:18

标签: python

昨天我设法使这段代码起作用,但是当我今天去尝试时,它只是循环自身,我不知道为什么这样做。

这是代码:

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)

此处的完整代码https://pastebin.com/K8fFQc0r

1 个答案:

答案 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将还原所有更改。直到您处于运行状态为止。