0

I have a short question concerning changing the value of a boolean variable.

bool = True

def boolean(boo):
    boo = False
    return boo

boolean(bool)
print(bool)

What am I missing? By returning the value of 'boo' inside the function boolean should do the job, shouldn't it?`

Thanks for answering.

Dimilo
  • 23
  • 4

1 Answers1

1

The boolean function is indeed returning False, but you are not doing anything with that returned value, and thuss python will throw it out. instead you should catch the returned value and put it back into the bool variable with:

bool = boolean(bool)

The full code would be:

bool = True

def boolean(boo):
    boo = False
    return boo

bool = boolean(bool)
print(bool)
Luke_
  • 745
  • 10
  • 23