Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>import os def Start(): print("Hello and welcome to my first Python game. I made it for fun and because I am pretty bored right now.") print("I hope you enjoy my EPIC TEXT GAME") play = input("do you want to play? (Y / N) ") def game2(): print("asd") input("asdsa") def game1(): print("THIS SHOULD BE PRINTED!! BUT IT'S NOT!!") word1 = input("what is the word? ") if word1.lower() == "password": game2() else: os._exit(1) Start() # &lt;- You never called start, which **declares** play (the variable) if play == "Y": game1() if play == "N": os._exit(1) </code></pre> <p>Your code is far from perfect. The way code works is that, it goes from top to bottom.. meaning, if you don't <strong>declare</strong> <code>play</code> it will never exists..</p> <p>And snice <code>play</code> is declared (created) in your function <code>Start()</code> you need to call start in order to check the value in <code>play</code>.</p> <p>It's ulgy, but heres a solution and an explanation to what you're doing and how it works.</p> <p>Also note: I tabbed your <code>if word1 == "password":</code> one more time, since you want to do the check after word1 is inputted... didn't realize that when editing your post.</p> <p>On the left screenshot, the green blocks is what's executed <strong>BEFORE</strong> the red line..<br> Once <code>play</code> tries be compared against <code>"Y"</code> it will fail because <code>play</code> was never created.. Just because you have it inside <code>Start()</code> doesn't mean you've created it.. you also need to <strong>call</strong> <code>Start()</code> in order for that code to be executed, otherwise Python will be <em>lazy</em> and ignore whatever is in the function <code>Start()</code> since it will assume you'll call upon it whenever you are ready to or need it to be accessed (saves time).</p> <p><img src="https://i.stack.imgur.com/cxtX1.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload