What is List in Python?
A list is a data structure used to store multiple values in a single variable.
Example:
numbers = [10, 20, 30, 40]
names = ["Kavi","Arjun","Ashok"
Values are arranged by index number starting from 0. You can print a value based on its position / index.
names = ["kavi","arjun","akash"]
print(names[0])
It will print the 0 index value of names list.
Lists are changeable (mutable). You can update the old value with new value in List using index number.
person_details = ["John", 25, "Europe"]
person_details[1]= 26
print(person_details)
Can store different data types in the same list
person_details = ["John", 25, 76.5, True]
Comments
Post a Comment