Exercise 35 - Triggering other Prompts?


Hello, I just typed my code for Exercise 36 (found here: https://pastebin.com/7bLNRq3q)

The first thing I noticed is in the gold_room(): https://pastebin.com/PSqLAk2M

How can you get over 1? You only trigger the “Nice, your not greedy, you win!” when you type 0 or 1 but anything above and you get “Man, learn to type a number” even though “how_much” is set to less than 50

My next question is about the bear area. This part: https://pastebin.com/zfKrGRm7

We never get to the “The bear gets pissed off and chews your leg off.”. Is that by design ?


This is a subset of the full code. You are right, the if-statement only handles 0, 1 or else.

This is setting you up for more code later. Keep going.


Yea i see, in Study Drill 5, i had to make it detect a regular string (full answer here: https://pastebin.com/EDEyc3HR )

One last question though. There is a “While True” loop (found on line 25 on the first pastebin in my code). Why do we need to make an infinite loop?


You need an infinite loop here because you don’t know how many loops you need in advance.


One thing you can do @MilkTaste01 is try out what you think the code should do. For example, if you think it should not use an infinite loop, then try to change it to not use one. You might come up with something better, and if not you’ll find out why I did it.


Thank you Zed.

I do get why we need the infinite loop. When we navigate through the bear room, we need to taunt the bear and then open the door which gets us to the gold room. However, when we remove the “while true” loop, after we taunt the bear, it ends the script.