How to create a list in Python

  • Post category:List

You can create a list in Python with the following code. If you want to learn Python, I strongly advise you to read This Book.

# Create a list of integers
new_list = [71, 72, 73, 74, 75]

# Create a list of strings
new_list = ['a', 'b', 'c', 'd', 'e']

# Create a list of mixed data types
new_list = [1, 'a', 2, 'b', 3, 'c']

# Create a list of lists
new_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

You can find related content from CodeAllow.