[Tutor] Concatenating Strings into Variable Names?
rmkrauter at yahoo.com
Mon Feb 2 14:06:34 EST 2004
> print the_answer
You can test these out:
print globals().get('the_answer',"Not a valid choice")
print locals().get('the_answer',"Not a valid choice")
I hope others comment on the right way - I'm interested in which is
considered the best, if any. The dictionary method posted by Don is good
too. The first and last two examples above provide a check for invalid
entries, similar to Don's method.
More information about the Tutor