Methods return a copy
Strings come with built-in tools called methods. Call them with a dot. None of them change the original — they hand you a new string.
name = " ada lovelace "
print(name.strip()) # "ada lovelace"
print(name.strip().title()) # "Ada Lovelace"
print("HELLO".lower()) # "hello"
print("python".replace("p", "P")) # "Python"
The ones you will use most: .upper(), .lower(), .strip(), .title(), .replace(old, new) and .split() (which breaks a sentence into a list of words).
Slicing takes a piece
Every character has a position number, starting at 0.
word = "Python"
print(word[0]) # P
print(word[-1]) # n — counting from the end
print(word[0:3]) # Pyt — positions 0, 1, 2; the stop value is not included
print(word[3:]) # hon — from 3 to the end
Finding patterns with regex
When you need to find a pattern rather than exact text, Python has the re module. re.findall(r"\d+", "I have 3 cats") returns ['3'], because \d+ means "one or more digits".