close

How to create List of Lists in Python

Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about How to create List of Lists in Python. so without wasting time lets learn about of this.

How to create List of Lists in Python

  1. Create List of Lists in Python

    to create List of Lists in Python just Use append(). By using append() you can make list of lists in python. It is very easy to use. Lets learn about of this by given below example: lst1 = [11,12,13] lst2 = [14,15,16] lst = [] lst.append(lst1) lst.append(lst2) print(lst) Output : [[11, 12, 13], [14, 15, 16]]

  2. How to create List of Lists in Python

    to create List of Lists in Python just Use list initializer. By using list initializer you can make list of lists in python. It is very easy to use. Lets learn about of this by given below example: lst1 = [19,11,9] lst2 = [97,54,45] lst3 = [lst1, lst2] print(lst3) Output : [[19, 11, 9], [97, 54, 45]]

  3. python create a list

    To create List of Lists in Python just Use append(). By using append() you can make list of lists in python. It is very easy to use. Lets learn about of this by given below example: lst1 = [11,12,13] lst2 = [14,15,16] lst = [] lst.append(lst1) lst.append(lst2) print(lst) Output : [[11, 12, 13], [14, 15, 16]]

Method 1: Use append()

By using append() you can make list of lists in python. It is very easy to use. Lets learn about of this by given below example:

lst1 = [11,12,13]
lst2 = [14,15,16]
lst = []
lst.append(lst1)
lst.append(lst2)
print(lst)

Output :

[[11, 12, 13], [14, 15, 16]]

Method 2: Use list initializer

By using list initializer you can create List of Lists in Python. It is very easy to use. Lets learn about of this by given below example:

lst1 = [19,11,9]
lst2 = [97,54,45]
lst3 = [lst1, lst2]
print(lst3)

Output :

[[19, 11, 9], [97, 54, 45]]

Method 3: Use list comprehension

By using list comprehension you can make list of lists in python. It is very easy to use. Lets learn about of this by given below example:

lst1 = [1, 2, 3,4]
mylst = [lst1 for i in range(3)]
print(mylst)

Output :

[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]

Conclusion

It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment