PYTHON BEGINNERS - 10 : LISTS FUNCTIONS

 IN THIS TUTORIAL YOU WILL LEARN ABOUT LIST FUNCTIONS.

NOTE: TRY ALL FUNCIONS 


lucky_nums = [1, 2, 3, 35, 46, 23, 4]
friends = ["Kevin", "Karen", "Roman", "Roman"]

# print(lucky_nums)
# friends.extend(lucky_nums)  #--> adds two or more list
# friends.append("SHAYAN")  #--> adds item at the last of list
# friends.insert(1, "Akhtar") #--> inserts element at the given index
# friends.remove("Kevin")   #--> removes the element from the list
# friends.clear()   #--> removes all item from the list
# friends.pop()  #--> removes last element from the list
# print(friends.index("Mike"))
# print(friends.count("Roman"))
# friends.sort() # --> alphabetical and ascending order
# print(friends)
# friends.reverse() --> reverses the list
# print(friends)
# lucky_nums.sort()
# print(lucky_nums)
# lucky_nums.reverse()
# print(lucky_nums)

friends2 = friends.copy() #--> makes a copy of list given
print(friends2)

Comments