Python List

List

Python list is used to store data. In a list, we can store multiple items in a single variable

Example:

thislist = ["ford", "audi", "aulto"]
print(thislist)

output

We can change the items that are in the list and we can also store duplicate items in the list. Items in the list that start with [0]

Add Duplicate Item

the list allows storing the duplicate item

thislist = ["ford", "audi", "bmw", "ford", "audi"]
print(thislist)

List Lenght

we can check list length using len()

thislist = ["ford", "audi", "BMW"]
print(len(thislist))

List Items – Data Types

List items can be of any data type:

list1 = ["ford", "audi", "BMW"]
list2 = [1, 5, 7, 9, 3]
list3 = [True, False, False]

Also, a list can store different data types

Example

list1 = ["abcd", 20, True, 45, "male"]

Leave a Reply