2017-06-13 148 views
-1

這是我正在做的遊戲,我似乎無法弄清楚如何使用while循環進行循環,而不使用任何計數或其他數字。如果你想知道這個遊戲是殭屍骰子。如何修復此循環?

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

你的代碼拋出立即'NameError',因爲'dice'沒有定義循環。 –

+0

你在哪裏定義骰子? –

+0

我假設他的骰子定義爲 –

回答

0

您使用它在你的`while`謂語前,你不打破循環,因爲con住宿爲"1"