Is it possible to concatenate two strings and call the resulting string as a variable?
For example, suppose I have a variable foo = "bar"
and for some very weird reason I wanted to call it with the strings "fo"
and "o"
such as this incomplete example:
foo = "bar"
weapon = "fo" + "o"
print(weapon)
In this case, Python will obviously output "foo"
. How do I instead get this to output "bar"
by using the variable weapon
?
I have already solved the problem a by creating a dictionary and using the resulting string as the key, but I am still curious if it is possible to call a variable using a concatenated string.
Thanks for any guidance!