A list is a collection of items that are
orderedandchangeable.
Lists are created using square brackets [] and each item in the list is separated by a comma.
You can access and manipulate elements of a list using its index. Some common operations you can perform on lists include appending, slicing, sorting, and removing elements.
Here's an example of how to create a list in Python:
fruits = ["apple", "banana", "cherry"]
List has some common actions you can get perform on a list in Python
You can access individual elements of a list using its index. The index of the first element is 0, and the index of the last element is -1. Here's an example:
my_list = ["apple", "banana", "cherry"]
print(my_list[0]) # Output: "apple"
print(my_list[-1]) # Output: "cherry"
You can modify individual elements of a list using their index. Here's an example:
my_list = ["apple", "banana", "cherry"]
my_list[1] = "orange"
print(my_list) # Output: ["apple", "orange", "cherry"]
You can extract a subset of a list using slicing. Slicing uses the colon operator to specify a range of indices. Here's an example: