How to use Lists in Python

Lists are one of the fundamental object types in Python and also one of the most useful. Lists provide a flexible tool for storing arbitrary collections of data. Also unlike strings they are mutable.

We can use various methods to slice, index, concatenate just as we did for strings.

Note that the original list remains unchanged even after manipulation. To create a new list using the old list you need to create a new object or use the append() method.

Lists can also nest other lists.

We can get to individual elements in the list using indexing.

You can modify a list using the append() or pop() methods.

You can remove and insert objects into the list at arbitrary locations.

Leave a Reply

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