【发布时间】:2015-02-13 17:03:23
【问题描述】:
我已经尝试了很多年如何让它发挥作用。它应该选择一个带有'from random import randrange'的随机数,然后是'x = randrange(1,3)。我在其他时候使用过那个生成器,然后它就可以工作了,但它不适用于这个:/。 代码如下:
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
顺便说一句,之前使用 'numberboy = 0' 以使其工作(numberboy 是变量,x)
【问题讨论】: