vendredi 13 février 2015

Python - why is my random number generator not working?

I've tried for ages on how to get this to work. It is supposed to choose a random number with 'from random import randrange' followed by the line 'x = randrange(1,3). I have used that generator at other times and it worked then but it will not work with this :/. Here is the code:



from random import randrange
numberboy == randrange(7,9)
if numberboy == "7":
print ("You unluckily fall into a pit!")
health -= 1
if health == "1":
print ("You drop to your knees and lie, filled with pain in the pit. You drop to the floor. Your quest is over.")
print ("Your health has fallen to " + str(health) + ". ")



if numberboy == "8" or "9":
print ("You could have fallen into a pit but you luckily didn't!")
print ("You find a path leading of to another room.")

print ("You walk down the path and find a light illuminating an elvish sword!")
print ("You walk out of an escape path and find youself coming out of a secret entrance at the clearing.")
import time


Btw, earlier on a use 'numberboy = 0' in order for it to work (numberboy is the variable, x)





Aucun commentaire:

Enregistrer un commentaire