โšกFREE Live Master Session: Code Your AI Companion for Kids

    Register for Free โ†’
    Free Worksheet ยท Interactive Python Engine

    Python StringsMethods, Slicing & f-Strings

    Master text manipulation in Python! Learn character indexing, string slicing, built-in methods like .upper() and .strip(), concatenation, and modern f-strings.

    ๐Ÿ“

    What is a String?

    In Python, a string (data type str) is a sequence of characters enclosed in single quotes ('...') or double quotes ("...").

    Real-world analogy

    Imagine letters printed on a train boxcar or beads threaded on a necklace. Each character sits in a specific order along the string. You can inspect individual letters, count how many there are, or format the message for display!
    ๐Ÿ“

    Text Representation

    Stores words, sentences, code, symbols, or even numbers formatted as text.

    ๐Ÿ”ข

    Zero-Indexed Sequence

    Each character has an index position starting at 0.

    ๐Ÿ”’

    Immutable

    Strings cannot be changed in-place. Modifying a string creates a new string.

    ๐Ÿ“

    Length with len()

    Use len(text) to get the total character count.

    Key vocabulary

    • String Literal โ€” text enclosed in quotes written directly in your code.
    • Character โ€” a single letter, number, space, or symbol inside a string.
    • Immutability โ€” once created, a string's internal content cannot be altered.
    • Escape Sequence โ€” special characters preceded by a backslash like \n (newline) or \" (quote).

    ๐Ÿงช Compact String Playground

    Run the script below to inspect a string and check its character count using len():

    ๐Ÿงช Compact String Playground

    Ready to run

    Python ScriptEditable
    1
    2
    3
    Variable Inspector

    No variables yet.

    Run your Python code to see them appear here live!

    Output & Console
    Output Console
    Press Run Code above to see Python output here.
    Real Python Execution & Tracing
    Interactive input() Supported
    1 / 6
    ๐Ÿš€ Ready to go further?

    Master Python String Manipulation with Live 1-on-1 Expert Tutors

    Worksheets are a fantastic start! Our Python Programming Course for Kids takes you from text manipulation to building real-world projects with personalised expert feedback.