Answer the question
In order to leave comments, you need to log in
Doesn't change the value of a variable in python?
I am not changing the value of a variable in python.
An excerpt from my code:
if musicState == "Off":
musicState = "On"
info.music = True
elif musicState == "On":
musicState = "Off"
info.music = False
Answer the question
In order to leave comments, you need to log in
1. Apparently, this is a piece of some function, and info is an instance of some class. We need to deal with this instance. Is it the same in all files or is it recreated in different files?
2. The values "On" and "Off" are capitalized here, perhaps somewhere else with a small or even a typo. It would be more logical to use the boolean value True or False, then the whole code would look much simpler:
musicState = not musicState
info.music = musicState
else:
assert False, f"musicState is {musicState}"
global musicState
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question