I have 3 variables of array so i created
Indexlist = range(0, 9)
For i in indexlist:
A = [i for i in indexlist]
B = [i for i in indexlist]
C = [i for i in indexlist]
So is there any simple way to declare?
I have 3 variables of array so i created
Indexlist = range(0, 9)
For i in indexlist:
A = [i for i in indexlist]
B = [i for i in indexlist]
C = [i for i in indexlist]
So is there any simple way to declare?
You can also make a copy of your list:
from copy import copy
Indexlist = list(range(0, 9))
A = copy(Indexlist)
B = copy(Indexlist)
C = copy(Indexlist)
Doing this, modifications on one of these 3 lists will not affect the other ones
Use this code. A, B, C = [range(1, 10) for x in range(3)]
Note that range(1, 10) is not list but generator. If you want the list, use this.
A, B, C = [list(range(1, 10)) for x in range(3)]
you can use:
A, B, C = [list(range(9)) for _ in range(3)]
or:
A = list(range(9))
B = list(range(9))
C = list(range(9))