I’m making a little RPG game, and I don’t know how to make a variable under while True be able to be changed,( I’m trying to make a travel system that changes the player’s location, and “none” is a location where the player starts, and it has no enemies whatsoever, and is under while true, meaning it can’t be changed, but I need to change it.)
Easy, put it outside the loop at the beginning of the program, or change it again after the none declaration if you don’t want anything outside the loop
location = "none"
while True:
enemies = {"forest": ["Bear","Wolf","Snake"], "desert": ["Fire Plant", "Scorpion", "Sand Worm"], "mountains": ["Giant Ice Spider", "Polar Bear", "Mammoth"], "none":["none"]}
enemy_options=enemy[location]
location = "change it anywhere in this loop if you want"
Or
while True:
enemies = {"forest": ["Bear","Wolf","Snake"], "desert": ["Fire Plant", "Scorpion", "Sand Worm"], "mountains": ["Giant Ice Spider", "Polar Bear", "Mammoth"], "none":["none"]}
location = "none"
enemy_options=enemy[location]
location = "change me after the location=none in this loop, if you want"
However, the first one is better and less restricted