I am using python
a5 = [1.1,1.3,15.4,13.3]
# and
numb = 5
aname = str('a')+str(numb)
print(aname[0])
I want to make variable name using str and number and then want to get value of that variable
I am using python
a5 = [1.1,1.3,15.4,13.3]
# and
numb = 5
aname = str('a')+str(numb)
print(aname[0])
I want to make variable name using str and number and then want to get value of that variable
If your variables are global, then you can use globals()[aname]
to get their value. If they are local, then use locals()[aname]
You Can Use Dictionary
name = "a"
value = True
a_dictionary = {name: value}
print(a_dictionary["a"])
the output will be True
What you want to use is the eval
function (docs).
For your example:
a5 = [1.1,1.3,15.4,13.3]
# and
numb = 5
aname = eval('a' + str(numb))
print(aname[0])