1. Clean up messy text
People type messy things: extra spaces, wrong capitals. Strings have methods to clean them. Each one gives you a new string (the old one is unchanged):
" asha ".strip()→"asha"(spaces removed at both ends)"asha".upper()→"ASHA","ASHA".lower()→"asha""asha verma".title()→"Asha Verma""chai".replace("i", "y")→"chay""banana".count("a")→3len("asha")→4
You can chain them: raw.strip().title().
raw = " rAHUL dravid "
name = raw.strip().title()
print(name)
print(name.upper())
print(name.lower().count("a"))
Challenge: Clean the name
Read a messy name. Make name the clean version with .strip().title(). Then print three lines. For aSHA verma they are:
Name: Asha VermaShout: ASHA VERMALetters a: 3(count the letter a in the lowercase name)