In some other programming languages I am used to, there was a way to dynamically create and call variables. How to do this in Python?
For example let's suppose variables called test1; test2 etc. up to test9, and I want to call them like this:
for n in range(1,10):
print concatenate('test', n)
Of course, the function concatenate is the one I am looking for.
What is the command to combine strings, integers and regular expressions in this way?
My example was a bad one, that made some of the answers suggest dictionary, or some other similar methods. It's either I am not too confident with them, or I can't use them in all cases. Here's another example:
Let's suppose we have a table of 4 rows and 4 columns, and the table has some numbers in it. I want to do some special mathematical operations, which has the row number, column number and the variable as inputs, and it outputs another row-column pair for another mathematical operation.
Logic suggests me that te easiest way to do this would be to have 16 variables, having row and column number in their names. And if I could do operations with the names of the variables, and also return the result and call it as another varialbe, the problem would be easy.
What about this context?