Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put Variable Value in a List Name?

Status
Not open for further replies.

rswarich

Technical User
Jun 7, 2001
7
US
I need to create several lists inside a loop.
The loop index should be in the names of
the lists.


blx="blx"

j=1
while j <= 100:
blx+j = [1,2,3,...]
j=j+1


The result I need is 100 lists:
blx1
blx2
blx3
.
.
.
blx100


Anyone have an idea about how to put a variable
name in the list names. Does not seem to work
for me, but I am just learning.



Thanks
 
Why not create a list of lists ?

[tt]
blx = [] # Create an empty list

for i in range(10):
blx.append( [1,2,3,4] )

# Print all the lists:
print blx

# Print the 4th list:
print blx[3]
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top