Python在print语句处停止

时间:2016-09-30 08:47:41

标签: python

while Winner == "":
    while First_Player_Turn == "Y":
        while rtd != "":
            try:
                rtd = input("{} press enter to roll the dice".format(First_Player))
                if rtd == "":
                    dice = random.randint(1, 6)
                    First_Player_Position = dice + First_Player_Position
                    steps_left = 50 - First_Player_Position
                    print("{} needs {} steps to finish".format(First_Player, steps_left))
                    if First_Player_Position >= 50:
                        Winner = "Y"
                    First_Player_Turn = "N"
                    Second_Player_Turn = "Y"
                    print("Test to see if this is printed - It is but not in wingide")
                    continue
             except:
                    print("Please press enter")                    
    while Second_Player_Turn == "Y":

我已多次测试过,我发现wingide没有显示经测试的部分,但普通的Python确实如此。我想要发生的是它已经通过First_Player_Turn循环进入Second_Player_Turn循环。

2 个答案:

答案 0 :(得分:0)

您没有显示字符串变量的初始化。您的程序从以下开始:

while Winner == "":
    while First_Player_Turn == "Y":
        while rtd != "":
  • 如果Winner初始化为"",则外循环将运行。
  • 如果First_Player_Turn初始化为"Y",则中间循环将运行。
  • 如果rtd 初始化为"",则内循环将会运行。

因为您还没有显示所有三个变量的初始化,所以您显然依靠魔术来启动正确的值。因为这不太可能,所以循环的 none 的赔率将会运行。

答案 1 :(得分:0)

我自己已经弄清楚了,rtd与其他rtd相比,对于浪费你的时间感到遗憾。