Preplp
Daily Python
Day 14Python~30 min

Strings

Methods, slicing, and text cleanup

Track progress0/15 days
x

What you'll learn

stripsplitjoinlowerreplaceslicing
  • Clean and transform user text
  • Build a simple text utility tool

Lesson & examples

Read the code, then the explanation — try changing values before the project.

Clean input
text = "  Hello, World!  "
print(text.strip().lower())

Today's exercise: Text Utility Tool

Menu to uppercase, count words, reverse, or replace text.

Steps

  1. 1

    Get text

    Ask for a sentence once at the start.

  2. 2

    Menu actions

    Apply strip, split, join, replace based on choice.

Full project source — copy into a folder or use the zip above

starter.py
text = input("Enter a sentence: ")

while True:
    print("\n1. Uppercase  2. Word count  3. Reverse  4. Replace word  5. Exit")
    c = input("Choice: ")
    if c == "1":
        print(text.upper())
    elif c == "2":
        print(len(text.split()), "words")
    elif c == "3":
        print(text[::-1])
    elif c == "4":
        old = input("Replace: ")
        new = input("With: ")
        print(text.replace(old, new))
    elif c == "5":
        break

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.