Python: List

in #steemjet3 years ago

Lists are very similar to arrays. They can contain any type of variable, and they can contain as many variables as you wish. Lists can also be iterated over in a very simple manner. Here is an example of how to build a list.

Lists - Learn Python - Free Interactive Python Tutorial.png

Accessing an index that does not exist generates an exception (an error).

Lists - Learn Python - Free Interactive Python Tutorial (1).png

Exercise
In this exercise, you will need to add numbers and strings to the correct lists using the "append" list method. You must add the numbers 1,2, and 3 to the "numbers" list, and the words 'hello' and 'world' to the strings variable.

You will also have to fill in the variable second_name with the second name in the names list, using the brackets operator []. Note that the index is zero-based, so if you want to access the second item in the list, its index will be 1.

Lists - Learn Python - Free Interactive Python Tutorial (2).png

Thank you soo much for reading and giving me an upvote I do appreciate it.

Coin Marketplace

STEEM 0.17
TRX 0.12
JST 0.028
BTC 55350.11
ETH 2887.18
USDT 1.00
SBD 2.27