Python 3D Academyবাংলা

Strings & f-strings in Python

Chapter 4: Strings & f-strings

4 short lessons, with 3D animations, quizzes and coding tasks.

The lessons

  1. Making strings: quotes and escapes

    A string (str) is a piece of text wrapped in quotes, and Python keeps exactly the characters between the quotes.

  2. Indexing and slicing

    Each character has a position number, its index, starting at 0; word[i] picks one character and word[start:stop] picks a piece up to, but not including, stop.

  3. String methods

    A method is a function that belongs to a value, called with a dot, and a string method always gives back a new string instead of changing the old one.

  4. f-strings: filling in templates

    Put f before a string's opening quote, and Python fills each { } hole with the value of whatever is inside it.