In Python, there are several operations that can be performed on lists. Here are a few examples:
Indexing: You can access individual elements of a list by using an index in square brackets. For example, given the list my_list = [1, 2, 3], you can access the first element with my_list[0].
Slicing: You can extract a sub-list from a list by using slicing. For example, given the list my_list = [1, 2, 3, 4, 5], you can get the sub-list [2, 3, 4] by using the slice my_list[1:4].
Concatenation: You can combine two lists into a single list using the + operator. For example, [1, 2] + [3, 4] will produce the list [1, 2, 3, 4].
Repetition: You can create a new list by repeating an existing list using the * operator. For example, [1, 2] * 3 will produce the list [1, 2, 1, 2, 1, 2].
Membership: You can test whether an element is in a list using the in operator. For example, 3 in [1, 2, 3] will return True, while 4 in [1, 2, 3] will return False.
Length: You can get the length of a list using the len() function. For example, len([1, 2, 3]) will return 3.
Modification: You can modify the elements of a list by assigning new values to them. For example, my_list = [1, 2, 3] and then my_list[1] = 4 will change the list to [1, 4, 3]. You can also modify multiple elements at once using slicing.
Deletion: You can delete elements from a list using the del statement. For example, del my_list[1] will remove the second element from my_list. You can also delete a slice of elements using slicing.
On this page of the site you can watch the video online List Operations: A Beginner's Guide | Python Tutorial #6 | Part - 2 with a duration of hours minute second in good quality, which was uploaded by the user Pythoneers 01 January 2023, share the link with friends and acquaintances, this video has already been watched 7 times on youtube and it was liked by 0 viewers. Enjoy your viewing!