我该如何解决这个循环?

时间:2017-06-13 17:07:45

标签: python python-2.7

这适用于我正在进行的游戏,我似乎无法弄清楚如何使用while循环循环而不使用任何计数或等号。如果你想知道,游戏是Zombie Dice。

print "If you would like to continue say \"1\" if you don't want to continue say \"2\"."
con=raw_input("Do you want to continue?")

while con == "1": 
    while dice in range (0,13): # This is for when the user wants to continue.
        print dice 
        dice[0] = random.randrange(0,13)
        print dice[0];
        dice[1] = (raw_input("Roll your First dice"))
        dice[1] = random.randrange(0,12)
        dice1 = ["brain","brain","brain","brain","shotgun","shotgun","shotgun","shotgun","shotgun","footprint","footprint","footprint"]
        print random.choice(dice1)
        print dice[1];  
        dice[2] = raw_input("Roll your Second dice")
        dice[2] = random.randrange(0,11)
        dice2 = ["brain","brain","brain","brain","shotgun","shotgun","shotgun","shotgun","shotgun","footprint","footprint","footprint"]
        print random.choice(dice2)
        print dice[2];  
        dice[3] = raw_input("Roll your Third dice")
        dice[3] = random.randrange(0,10)
        dice3 = ["brain","brain","brain","brain","shotgun","shotgun","shotgun","shotgun","shotgun","footprint","footprint","footprint"]
        print random.choice(dice3)
        print dice[3];



# This code is for when the player does not want to continue.

    print "You choose \"No\" Second players turn"
    import random
    dice[1] = raw_input("Roll your First dice")
    dice[1] = random.randrange(0,13)

1 个答案:

答案 0 :(得分:1)

由于con保持为"1"

,因此您不会中断循环
相关问题