🎓 All Courses | 📚 Python Programming Syllabus

📋 Study this course on TaskLoco
#python-programming#strings#text

Strings — Text Manipulation

Strings are sequences of characters. Immutable in Python.


Creating strings:

s1 = 'single quotes'
s2 = "double quotes"
s3 = """triple quotes
for multi-line"""

Essential string methods:

s = "Hello World"
s.upper()          # "HELLO WORLD"
s.lower()          # "hello world"
s.strip()          # removes whitespace
s.replace("World", "Python")  # "Hello Python"
s.split(" ")       # ["Hello", "World"]
len(s)             # 11

f-strings (use these):

name = "Alice"
age = 30
print(f"My name is {name} and I am {age} years old.")

Indexing & slicing:

s = "Python"
s[0]     # "P"
s[-1]    # "n"
s[1:4]   # "yth"
s[::-1]  # "nohtyP" (reversed)

YouTube • Top 10
Python Programming: Strings
Tap to Watch ›
📸
Google Images • Top 10
Python Programming: Strings
Tap to View ›

Reference:

Wikipedia: String

image for linkhttps://en.wikipedia.org/wiki/String_(computer_science)

📚 Python Programming — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT