list of list python code example
Example 1: how to make a python list
listName = [1,2,3,4]
Example 2: create list python
# empty list
my_list = []
# list of integers
my_list = [1, 2, 3]
# list with mixed data types
my_list = [1, "Hello", 3.4]
Example 3: list of lists python
listOfLists = [[1,2,3],['hello','world'],[True,False,None]]
Example 4: python list
# example of list in python
myList = [9, 'hello', 2, 'python']
print(myList[0]) # output --> 9
print(myList[-3]) # output --> hello
print(myList[:3]) # output --> [9, 'hello', 2]
print(myList) # output --> [9, 'hello', 2, 'python']
Example 5: how to make lists in python
blah = [uchoose,etc.]
Example 6: python list and list
a = ['apple', 'banana', 'pear']
b = ['fridge', 'stove', 'banana']
a & b == ['banana'] #True