# 《笨办法学Python》 第35课手记

### 《笨办法学Python》 第35课手记

```from sys import exit

def gold_room():
print "This room is full of gold.  How much do you take?"

next = raw_input("> ")
if "0" in next or "1" in next:
how_much = int(next)
else:
dead("Man, learn to type a number.")

if how_much < 50:
print "Nice, you're not greedy, you win!"
exit(0)
else:

def bear_room():
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move the bear?"
bear_moved = False

while True:
next = raw_input("> ")

if next == "take honey":
elif next == "taunt bear" and not bear_moved:
print "The bear has moved from the door. You can go through it now."
bear_moved = True
elif next == "taunt bear" and bear_moved:
elif next == "open door" and bear_moved:
gold_room()
else:
print "I got no idea what that means."

def cthulhu_room():
print "Here you see the great evil Cthulhu."
print "He, it, whatever stares at you and you go insane."

next = raw_input("> ")

if "flee" in next:
start()
else:
cthulhu_room()

print why, "Good job!"
exit(0)

def start():
print "You are in a dark room."
print "There is a door to your right and left."
print "Which one do you take?"

next = raw_input("> ")

if next == "left":
bear_room()
elif next == "right":
cthulhu_room()
else:
dead("You stumble around the room until you starve.")

start()```

### 本节课涉及的知识

whlie true：这是一种获得无限循环的常用方法，因为判断表达式的值本身就是True，while循环将 无限进行下去。

256 篇文章54 人订阅

0 条评论

## 相关文章

### 天下无难试之HashMap面试刁难大全

HashMap的结构无疑是Java面试中出现频率最高的一道题，这个题是如此之常见，应该每个人都会信手拈来。可是就在我经历过的无数【允许我夸张一下】面试当中，能完...

11120

35390

19670

27860

34380

### Java函数式开发——优雅的Optional空指针处理

在Java江湖流传着这样一个传说：直到真正了解了空指针异常，才能算一名合格的Java开发人员。在我们逼格闪闪的java码字符生涯中，每天都会遇到各种nu...

14020

12440

85960

33450

26170