List: Ordered, indexed, changeable, and allow duplicate values.
List= [“a”, “b”, …]

Tuple: Ordered, unchangeable, and allow duplicate values.
Tuple= (“a”, “b”, …)

Set: Unordered, unchangeable, and disallow duplicate values.
Set= {“a”, “b”, …}

Dictionary: Ordered, changeable, and disallow duplicate values.
Dictionary= {“a”:”x”,
“b”:”y”, …}

MethodDescription
append()Adds an element at the end of the list Usage: list.append(elmnt)
clear()Removes all the elements from the list Usage: list.clear()
copy()Returns a copy of the list Usage: x=list.copy()
count()Returns the number of elements with the specified value Usage: x=list.count(value)
extend()Add the elements of a list (or any iterable), to the end of the current list Usage: list.extend(list2)
index()Returns the index of the first element with the specified value Usage:x=list.index(elmnt)
insert()Adds an element at the specified position Usage: list.insert(poselmnt)
len()Determines how many items a list has. Usage: x=len(list)
pop()Removes the element at the specified position Usage: list.pop(pos)
remove()Removes the first item with the specified value Usage: list.remove(elmnt)
reverse()Reverses the order of the list Usage: list.reverse()
sort()Sorts the list Usage: list.sort(reverse=True|False, key=myFunc)

Leave a Reply

Your email address will not be published. Required fields are marked *