If you want to create tens of thousands of variables in Python, is there a way to do this in a for statement. What I want is a code that, when given a number and a value, can create that number of variables and assign them that value.
def createVars(num, somevalue): for x in range(num): var1 = somevalue var2 = somevalue The idea is for the loop to continue making variables with reliable names(var3, var4, etc.) and assigning them to some given value. How could you make this system that could create variables without explicitly having to name all of them?
localsorglobalsmylist[0]ormylist.get('var_0')is just as real a variable asvar_0?