Python : creating multiple lists

前端 未结 5 2189
渐次进展
渐次进展 2020-12-10 06:38

I\'m trying to create multiple lists like the following:

l1 = []  
l2 = []  
..  
ln = []  

Is there any way to do that?

5条回答
  •  没有蜡笔的小新
    2020-12-10 07:29

    You can simply use a for loop to create n lists.

    for i in range(10): a_i = [i] #Stores the corresponding value of i in each a_i list. print(a_i)

    The variable a_i changes as i increments, so it becomes a_1, a_2, a_3 ... and so on.

提交回复
热议问题