MODIFICATION/UPDATE

CHANGING ELEMENT

months = ["Jan", "Feb", "Dec", "Apr"]
months[2] = "Mar"
print(months)

CLEARING LIST

#!/usr/bin/env python3

def main() -> None:
    
    numberList = [10,20,30,40,50,60];
    print("List Length: ", len(numberList));
    
    #clear list
    numberList = [];
    print("List Length: ", len(numberList))

if __name__ == "__main__":
    main();

LIST UPDATE FUNCTIONS

These are the four major functions that can be used to update any given list and its items.

  • append() This function helps in adding a new item at the end of the list.

  • insert() This function helps in adding a new item at a specific position in the list. You can exactly specify which position you want to add the new item.

  • remove() This is used to remove the first matching element from a list. You can exactly specify which item you want to remove from the list.

  • pop() This is used to remove the element at the specified position.

INSERT

Last updated