Methods of List Object in Python

[] is the symbol we use in Python to create a list.

A list can hold multiple items of any type (numbers, strings, even other lists) and we can add, remove, or access items using their position (index).


List has some built-in Methods because it’s an object, the ones you often use are methods like:

  • append() – add an item to the end of the list

  • extend() – add multiple items at once

  • insert() – insert item at a specific position

  • remove() – remove a specific item

  • pop() – remove item by index

  • sort() – sort the list

  • reverse() – reverse the list

  • count() – count how many times a value appears

  • index() – find index of a value

Comments

Popular posts from this blog

What is Artificial Intelligence? What is Machine Learning? What is Data Science? how they are related to each other?

Linear Algebra - What is it?

What is a Python Library?