PYTHON CORE · LESSON 44

Gather words.

Method of join · about 11 minutes

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

List by line

join combines words from the list. Before the dot, specify the text that stands between the words.

words = ["кот", "пёс"]
print(" и ".join(words))

✦ «кот и пёс» will appear.

STEP 2

The divider can be changed

If you put a comma and a space between the words, you get a neat list to read.

colors = ["синий", "жёлтый"]
print(", ".join(colors))

✦ «синий, жёлтый» will appear.

IN-CLASS PRACTICE

Type the code yourself

Dial a list and connect words through a comma with a space.

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

Solve it yourself

Create words from «кот» and «пёс». Connect them via « и » with join and output the result.

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

Opening up your homework