Functions don't work in Pycharm?

Hi there.

Why won’t this code run???

def rules():
“”“1. When you get a question, enter the number behind the choice you want to choose
2. Don’t cheat. (Other wise how is the game fun?
3.You have an inventory
4.Have fun!”""

def instructions():
“”“You wake up and find yourself in a dark room.
You do not know where you are, or what happened to you.
You are a aware that there is a dim light behind you”""

inventory = ()

print('Welcome to escape the mansion!')
input('\nPlease press enter to continue...')

instructions()
print('''\nYou can either...

           1.Go through the door in front of you
           2.Go through the door on your left
           3.Turn Behind you''')

input('>>>')

I’m guessing because quite a lot of indentation is missing?

Your interpreter is probably telling you what’s wrong when you are running your intact version of the above misformatted code!

no no.
here.

def rules():
 """1. When you get a question, enter the number behind the choice you want to choose
    2. Don't cheat. (Other wise how is the game fun?
    3.You have an inventory
    4.Have fun!"""

 def instructions():
    """You wake up and find yourself in a dark room.
        You do not know where you are, or what happened to you.
          You are a aware that there is a dim light behind you"""

    inventory = ()

    print('Welcome to escape the mansion!')
    input('\nPlease press enter to continue...')

    instructions()
    print('''\nYou can either...

               1.Go through the door in front of you
               2.Go through the door on your left
               3.Turn Behind you''')

    input('>>>')

Now you’re just lying to me. That does run. No errors.
Perhaps you are expecting more than just running, perhaps you expect it do do something specific, what would that be?

But why when i run it in Pycharm this is what I get.

Process finished with exit code 0

I use Pycharm CE
Why does that happen?

Because it successfully ran. That’s what exit code 0 means.

But it is supposed to display the instructions

and ask the user for which choice they want to choose before exiting.
So why does it run and exit without doing all that?

Because that part of the code doesn’t get executed. Where is it located, and how does one execute that part?

…Did you just remove all your replies or is there somebody else rummaging around for no good reason?
Nope, just a spam filter being triggered. Fixed it.

Okay here we go…

That first print statement.
Why does that not print anything?
It is supposed to execute itself when you run the program and say: Welcome to Escape the mansion.

See above reply really. I was just about to type exactly the same thing.

should I use something other than pycharm?

Your problem is in the code. Your code simply doesn’t say to execute those lines.

Python reads your code. Two functions are created. And then your program is done. That’s all your code says should happen.

Is this to do with CC? If it’s not it should be in the corner bar.

1 Like

how should i change it?

so that it actually does something?

I just can’t find it in me to answer “how do I fix it”, because that would be me doing this all for you.
That’s for you to figure out.

pm:ing me certainly doesn’t help.

ahhhhh.

Answer = I am never going to find it
I just don’t see anything wrong with it in my view.

Well. This is the end of the road for text adventure games for me.

Thanks for your help.

There’s nothing that says that you can’t ask for help with homework.

But you do need to show that you’re looking to learn what needs learning to solve it yourself rather than looking for a quick fix without having to understand it.

1 Like