CodeAgeBy Sitezack
Python for MakersAutomate your data0 XP
Chapter progress0/6

Lesson 2 of 7

Slice up text

Data often arrives as raw text: "12,7,19". The split(",") method cuts the string into a list of pieces.

Each piece is still text: int(piece) converts it into a number so you can calculate.

line = "3,5"
parts = line.split(",")   # ["3", "5"]
print(int(parts[0]) + 1)  # 4

🎯 Your goal

From line = "12,7,19", build the list values holding the three integers [12, 7, 19] (split then int in a loop), and print values.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO