Ex43 how to get past more difficult rooms?


#1

Hi there,

I am working on ex43 from the book LPTHW… In the study drill of ex43, there’s a question that asks us to add some codes to get past more difficult rooms. The author could do it with two words, which honestly kinda blow my mind off xd. Does anyone know how to do this? I’d really appreciate it for any help!

xx


#2

Maaaaybe, can you reply with a direct quote so that I know what you’re exactly talking about?


#3

yeah sure. so the direct quote goes: 4. Add cheat codes to the game so you can get past the more difficult rooms. I can do this with two words on one line.

Shaw, Zed A… Learn Python 3 the Hard Way: A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code (Zed Shaw’s Hard Way Series) (p. 177). Pearson Education. Kindle Edition.


#4

Ok, let’s see if this little session helps you figure it out:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1
>>> i = False
>>> 
>>> worked = x or i
>>> worked
1
>>> worked = i or x
>>> worked
1
>>> i = True
>>> worked = i or x
>>> worked
True
>>> 
>>> code = '1234'
>>> guess = 'cheater'
>>> 
>>> code == guess or 'cheater'
'cheater'
>>> code
'1234'
>>> 
>>> # another way
... guess == code or guess == 'cheater'
True
>>>