So, this is Part 5 of our Python Tutorial Series and in this Video we talked about different list functions.
Code :
append() Adds an element at the end of the list
clear() Removes all the elements from the list
copy() Returns a copy of the list
count() Returns the number of elements with the specified value
index() Returns the index of the first element with the specified value
insert() Adds an element at the specified position
pop() Removes the element at the specified position
remove() Removes the first item with the specified value
reverse() Reverses the order of the list
sort() Sorts the list
my_list = ["candy", "vim bar", "bhindi"]
numbers = [2,3,5,1,4,5,89,55,8,5,5,78,9,9,9,9,9,9,9,9,9,9,9]
my_list.append("pens")
my_list.clear()
new_list = my_list.copy()
x = numbers.count(9)
y = numbers.index(5)
numbers.insert(3, 58)
my_list.extend(["pens", "lollypop"])
my_list.pop(1)
numbers.remove(9)
my_list.reverse()
numbers.sort(reverse=True)
print(numbers)
Join My Discord : / discord
Thank you Guys for your support. If you have any Doubt related to this Video ask me in Comments Down below and join my Discord Server.
And Don't try to call me I was just kidding.