I am trying to get input from a user into a variable but instead of a string, float or integer I want it to assign a different variable which is already defined. Pseudo-ish example:
xy = 23
a = raw_input("Enter a variable") xy
print (a)
23
Yes, this could be controlled with an if variable but for many variables this is not very practical I believe? I have no problem typing it just wondering wouldn’t it be bad practice?
Are you looking for something like this?
The task of adding a check in case the user enters an unkown variable is left to the reader…
Also beware of the potential security problems of this approach. A more secure way would be to restrict the evaluation scope by defining specific
dicts thatevalshould be using. Read more inhelp(eval).