Skip to content
Guest
Learn Python · Course Syllabus Show lessons
Data Structures · 7 min read · Beginner

Strings, Methods & Slicing

Clean, split, join, and slice text effortlessly with .strip(), .split(), .join(), .replace(), and slice steps.

What you'll learn

  • Clean messy user input with .strip(), .lower(), and .replace()
  • Convert between strings and lists using .split() and .join()
  • Slice substrings and reverse sequences cleanly with [start:stop:step]

Python strings are immutable, so methods like .strip(), .lower(), and .replace() always return a new cleaned string and chain together cleanly.

Fill-in-the-Blank Exercise

Split & Join Strings

Split the CSV string on commas and join the items with ' | '.

tags = "html,css,python".(",")
display = " | ".(tags)

Try It Yourself

PythonString Cleanup & Slicing
Python Output (WebAssembly / Pyodide)

Click Run Python to execute real Python 3 right in your browser.

Check Your Understanding

Score: 0 / 1

1. What does `'-'.join(['a', 'b', 'c'])` return?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind