-1

This is for a game I'm working on and I cant seem to figure out how to loop with the while loop without using any count or etc numbers. The game is Zombie Dice if you wanted to know.

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)
RedEye
  • 1
  • 2
  • 1
    your code throws an immediate `NameError`, since `dice` is not defined before you use it as a predicate in your `while` loop. – Adam Smith Jun 13 '17 at 17:14
  • Where do you define dice? – Rolf of Saxony Jun 13 '17 at 17:15
  • i was presuming he had dice definedbeforehand – Jason V Jun 13 '17 at 17:16
  • also, not relevant to the question, why did you make it 'dice' with 12 values instead of 2 die's with a value of 6 each? for future concept of object oriented programming, it might be better to think these types of things through – Jason V Jun 13 '17 at 17:18
  • For what it's worth, I think [this question](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) has the answers you're looking for. – Adam Smith Jun 13 '17 at 17:30
  • and irrelevant, but I've never seen a dice game with a d12, d11, and d10, so your implementation is wrong somehow. Not to mention you're rolling those dice, then ignoring their result, and printing an unrelated result, then printing the result of the random roll? – Adam Smith Jun 13 '17 at 17:31

1 Answers1

1

You don't break the loop because con stays as "1"

Apexdev
  • 147
  • 6