Im new to python and I stumbled on this problem, I would like to call a specific element in an array, but the array name is controlled by another array:
array1 = ["foo","bar","fubar"]
array2 = ["array1","array3","array4"]
number = 2
inter = array2[0]
test = inter[number]
#what im trying to achieve: test = array1[2]
#expecting: fubar
#what im getting: r
print(test)
Thanks guys :)
listobjects. But anyway, you simply have strings in your second list. The fact that those strings happen to be the same as the variable names is nothing those lists know about. You can dynamically execute strings as code, but there is no need for that, it is a fundamentally bad design choice. Use another data structure, like a dict, if you want to map strings to other objects.dictto map strings to objects?