I come from PHP background, and I am trying to print each iteration. I can not understand how to do it in Python
>>> a0, a1, a2 = [12, 5, 8]
>>> b0, b1, b2 = [5, 9, 11]
>>> categories = [0, 1, 2]
>>> for i in categories:
print(a+i)
Error:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'a' is not defined
>>> for i in categories:
... print('a'+i)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>> for i in categories:
... print(a+str(i))
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'a' is not defined
I know it is basic, but I do not know how to solve it.
Edit:
>>> print a0
12
>>> print a2
8
a0, a1, a2 is variable. Since I have 0,1,2 in for I don't need to write a0, a1, a2, b0, b1, b2 manually.