Q:

Can I make a variable name with some calculation in python

I like to make a variable with some calculation like below

'apple'+str(123)='orange'

expected below

apple123='orange'

It looks simple but is not working.

A:

You can do that using globals()
Example:
globals()['apple'+str(123)]='orange'
print (apple123) # will print orange
Reference: https://docs.python.org/3/library/functions.html#globals

