0

I'd like to have a function that receives a list of strings and converts them to variable to be used with some extra constant prefix

For example: element_list=['em1', 'em2', 'em3']

def myFunction(list):
    for element in list:
        XXX
        get_data(pref.element)

Where the pref.element shall be already a variable name. What I'm missing is the XXX.

user1977050
  • 496
  • 1
  • 6
  • 18
  • The real question here is: why do you care about variable names? The `get_data` function does not have access to that name, so what's the point? – user2390182 Feb 08 '21 at 15:23
  • 1
    Are you just looking for a [`dict`](https://docs.python.org/3/tutorial/datastructures.html#dictionaries)? – 0x5453 Feb 08 '21 at 15:24
  • Where do the references of the existing variables live now? – JacobIRR Feb 08 '21 at 15:24

0 Answers0