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
  • 1,048,767
  • 296
  • 4,058
  • 3,343
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
  • 32,567
  • 20
  • 113
  • 146
  • Thank you, I just realized this and was posting a reply when the question was closed. – Alex Sep 19 '14 at 21:09