0

I have the following code:

curtains = 0

def bedroom_curtains_open():
    print ("You open your curtains to reveal that it is very dark out.")
    print ("It looks to be about 2am, what woke you?")
    curtains = 1
    bedroom_up()

This, however doesn't change the variable curtains to 1, why is this?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
Alex
  • 21
  • 1

1 Answers1

0

Declare global curtains inside the function.

Then it knows to bind curtains to the global, rather than create a new local in the namespace of the function.

smci
  • 29,564
  • 18
  • 109
  • 144
  • Thank you, I just realized this and was posting a reply when the question was closed. – Alex Sep 19 '14 at 21:09