Lists are used when you want to store multiple values in one variable.
A list is a collection of multiple values stored in a single variable. Lists are ordered and changeable.
fruits = ["Apple","Banana","Mango"] print(fruits)
List elements are accessed using index numbers. The first index starts from 0.
colors = ["Red","Blue","Green"] print(colors[0])
numbers = [10,20,30] numbers[1] = 50 print(numbers)
append() method adds a new item at the end of the list.
students = ["Amit","Riya"]
students.append("Rahul")
print(students)
fruits = ["Apple","Mango"]
fruits.remove("Apple")
print(fruits)
skills = ["Python","HTML","CSS"]
print(skills)
skills.append("JavaScript")
print(skills)
Yes, a list can store numbers, strings and other data types together.
Yes, lists are mutable, which means values can be updated.
Square brackets [] are used to create lists.