1
"a"+str(1)=2
File "<ipython-input-44-929460161ba7>", line 1
"a"+str(1)=2
^
Syntaxerror: can’t assign to Operator
I want to create a series of variables a1 a2 A3 an and then associate to a value each one
1
"a"+str(1)=2
File "<ipython-input-44-929460161ba7>", line 1
"a"+str(1)=2
^
Syntaxerror: can’t assign to Operator
I want to create a series of variables a1 a2 A3 an and then associate to a value each one
2
Make a list instead of trying to create variables programmatically (which is possible, but not a good idea):
a =[]
a[1] = 2
I believe that’s what you want to do.
That’s what I wanted to do.
Remember to mark as the correct answer to help others who may have the same question.
Browser other questions tagged string python-3.x
You are not signed in. Login or sign up in order to post.
Sorry in Python 3.5 am new here
– Catia C Silva
I don’t know much about python but I wouldn’t be simpler to use an array?
– rray
I want to create a series of matrices that depend on quantity of elements, each matrix I would like to put a name like this, but I’m not able to do, maybe I’m thinking wrong, I’m starting to program.
– Catia C Silva
Hello Catia, I can’t quite understand what you’re trying to do...
"a"
is a literal (a string), not a variable.a1 = 2
? Try to edit your question and explain better what you are trying to do.– Anthony Accioly