Advice apreciated :)
[code]
# My goal is to change the contents of a chosen variable
a1 = 33
a2 = 22
input = "a1" # raw_input(">-")
#Command Dict.
comdic = {"a1":a1,"a2":a2,}
# Geting information works just fine
print comdic[input], a1
# changing the choosen variable does not
comdic[input] = 1337
# as seen here, "a1" stays the same
# but a new unknown variable inherits 1337
print comdic[input], a1
[/code]
>>334430
You have 2 different things:
- a1 the variable, and
- 'a1', the key of comdic corresponding to the value 33
Changing 'a1' in the dictionary doesn't touch the actual a1 variable.
>>334437
that explains the unknown variable, thx anon.
Now i just need to figure out how to change the original variable.
>>334441
Uh, that should be trivial. Or am I misunderstanding what you're asking?
>>334430
OP, click this and come back once you've completed it: https://www.codecademy.com/courses/introduction-to-python-6WeG3/0/1