PYTHON CORE · LESSON 07

List element

How to get one thing · about 11 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Every thing has a number.

Python starts counting places from scratch. The first thing is number 0, the second is number 1.

pets = ["кот", "пёс"]
print(pets[0])
Places on the list
Place 0котPlace 1пёс

✦ A cat will appear on the screen.

STEP 2

Square brackets looking for

After the name of the list, put square brackets with the number. There's only one thing you can take.

colors = ["жёлтый", "зелёный"]
print(colors[1])

✦ Number 1 gives the second word: зелёный.

IN-CLASS PRACTICE

Type the code yourself

Take an example and pay attention to the number in brackets.

pets = ["кот", "пёс"]
print(pets[1])
Open the editor for class work
HOMEWORK

Solve it yourself

Create fruits from «яблоко», «груша», «банан». Only remove the second fruit using its number.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework