Lists in Python

filler(58)
Published in
#coding
Words
156
Reading
1 min
7y
Listen to this post
~1 min

Large data?

Lists can help.

Name your list

So, for example, you want to make a list of the fruits you want to buy.

Write it out as :

py.lists.JPG

Write it out as shown in the image. Then print it.

You can access any single item from the list.

The indexing starts at zero. So, the third item would actually be the second in the list.

Items can be accessed backward too and this is done by using negative values.

-1.JPG

Now, what if you wanted to access items after a certain position. That is possible too.

lists py.JPG

Just type the code as above. You can experiment with this to understand it more, practically.

Suppose you want to replace it. It is easy. Just replace the value and print.
replace.JPG
As you can see, banana is replaced by jackfruit

The very basic list functions were cited above.

I hope you enjoy learning Python.

images - screenshots of Google colab

Lists in Python | Ecency