Page 84 - tp_Modula_v2.0
P. 84
remove( ) Remove first element from the list
index( ) Returns the index of first element of the list
count( ) Returns the occurrence (number of times) of a particular element in the list
pop([i]) Removes and returns item at the ‘i’ location in the list
copy( ) Returns a copy of the list
clear( ) Removes all the elements from the list and returns an empty list
sort( ) Sorts all the elements in the list
reverse( ) Reverses the order of the elements in the list
Program 6: Python built-in methods.
Program6.py
File Edit Format Run Options Window Help
list = [13, 25, 41, 63, 82]
list.append(19)
list.extend([26, 43, 55])
print("After append and extend:", list)
list.insert(1, 302)
print("After insert:", list)
list.remove(63)
print("After remove:", list)
print("Index of 13:", list.index(13))
print("Count of 41:", list.count(41))
list.reverse()
print("After reverse:", list)
popped_item = list.pop(2)
print(f"After pop (removed {popped_item}):", list)
list_copy = list.copy()
print("Copy of the list:", list_copy)
list.sort()
print("After sort:", list)
list.clear()
print("After clear:", list)
82 Touchpad MODULAR (Version 2.0)

