spelling_dict = {
"abc" : "ABC",
"apple" : "Apple",
"tortose" : "Tortoise"
}
def spellcheck(line):
for word, correction in spelling_dict.items():
# Pad words with a space on either side
word = word.center( len(word) + 2 )
correction = correction.center ( len(correction) + 2 )
line = line.replace(word, correction)
return line
myphrase = "For apple, I want to capitalize both occurrences of apple."
fixedphrase = spellcheck(myphrase)
print(fixedphrase)