Split a CSV Line
Beginner · Write the code · from Every Python String Method Explained with Examples
From the lesson: Every Python String Method Explained with Examples
Strings in Python come with a toolbox of built-in methods. These methods let you change case, remove extra spaces, search for words, split text apart, and much more.
Read the lessonYou have a line of comma-separated values. Split it into individual values and print each one on its own line.
Expected output:
Alice
25
New York
Engineercsv_line = "Alice,25,New York,Engineer"
# Split the line by commas and print each value
More string methods exercises
- Clean Up User InputBeginner
- Count Word OccurrencesBeginner
- Replace All OccurrencesBeginner
- Fix the Bug -- find() vs index()Beginner
- Validate a UsernameBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz