Functions don't work in Pycharm?

python

#1

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('>>>')

#2

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!


#3

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('>>>')

#4

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?


#5

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?


#6

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


#7

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?


#8

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.


#9

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.


#10

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


#11

should I use something other than pycharm?


#12

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.


#13

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


#14

how should i change it?


#15

so that it actually does something?


#16

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.


#17

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.


#18

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.


#20