Loading…
Before reading files, let's practice string processing.
| Method | Description |
|---|---|
| .strip() | Remove whitespace |
| .split(",") | Split by delimiter |
| .lower() | Lowercase |
| .replace(a, b) | Replace a with b |
line = "John,25,Engineer"
parts = line.split(",")
name = parts[0] # "John"
age = int(parts[1]) # 25
Given the string data = "Product:Laptop,Price:999,Stock:50", extract and print just the price (as a number).
Downloading Python… (one-time, ~10 MB)
This runs entirely in your browser and is cached for next time.