0

I am calling the same function with different parameters several times in the same script. Each time I want to save the results from the function under a different name so I can call several of these results later. How can I create a variable variable name?

Below a short example, by naming the variable ID in the function input to, for instance, 5 and want my variable name to become result_5.


def function_name(ID, x):

    global result_ID
    result_ID = x + 2

    return result_ID
Appeltje456
  • 15
  • 1
  • 4

0 Answers0