python变量定义是什么意思_Python说变量没有定义,但它是……不是吗?

我是一个完全的编程新手,我目前正在通过LPTHW。在

我现在正在做这个。但是,当我到达“cabin”时,终端告诉我“cabin”变量没有定义。事情就是这样。在

代码如下:print "You enter a dark room with two doors. Do you go through door #1 or door #2?"

door = raw_input("> ")

if door == "1":

print "There's a giant bear here eating a cheese cake. What do you do?"

print "1. Take the cake."

print "2. Scream at the bear."

bear = raw_input("> ")

if bear == "1":

print "The bear eats your face off. Good job!"

elif bear == "2":

print "The bear eats your legs off. Good job!"

else:

print "Well, doing %s is probably better. Bear runs away." % bear

print "You have now entered a forest clearing. What do you do now?"

print "1. Take the left fork of the path."

print "2. Take the right fork of the path."

print "3. Go straight into the forest itself, not on any path."

path = int(raw_input("> "))

if path == 1:

print "There is a pack of wolves on the path. They chase you down and eat you."

elif path == 2:

print "A forest ranger catches you and kills you for your booty. Good job, trespasser!"

else:

print "You trek through the forest and find an abandoned log cabin. What do you do?"

print "1. Look inside the cabin."

print "2. Ignore it and continue."

print "3. Set up camp for the night beside the cabin, have a quick look inside but sleep in your camp."

cabin == int(raw_input("> "))

if cabin == 1:

print "You find some tinned food and a rifle with a full magazine of ammunition. What do you do now?"

print "1. Stay the night at the cabin."

print "2. Head out into the woods and continue trekking overnight."

plan = raw_input("> ")

if plan == "1":

print "The cabin burns down during the night and you die. Bad luck!"

else:

print "You stumble around in the dark, fire all your ammunition off at shadows, and get eaten by wolves. Bad luck!"

elif cabin == 2:

print "You stumble through the forest in the dark and get eaten by a bear. Oh well."

else:

print "The cabin burns down overnight but you are fine. The next morning you find your way out of the forest and back to town. Well done!"

elif door == "2":

print "You stare into the endless abyss at Cthulu's retina."

print "1. Blueberries."

print "2. Yellow jacket clothespins."

print "3. Understanding revolvers yelling melodies."

insanity = raw_input("> ")

if insanity == "1" or insanity == "2":

print "Your body survives powered by a mind of jelly. Good job!"

else:

print "The insanity rots your eyes into a pool of muck. Good job!"

else:

print "You stumble around and fall on a knife and die. Good job!"

Powershell给出以下错误:

^{pr2}$

现在,当我用“path”变量处理时,这个方法起作用了,那么这里的问题是什么?我是不是错过了一些明显而愚蠢的事情?在

对不起,对不起。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值