Think Python X8

From XPUB & Lens-Based wiki

Exercise 8.x.1

Strings have a function called replace:

S.replace (old, new[, count]) -> string

Return a copy of string S with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.

Write a function removechars:

replacechars(old, new, string)

So that all characters in old get replaced by new in string, for instance:

replacechars("aeiou", "", "Tomato")
=>
Tmt
	
replacechars("aeiou", "*", "Tomato")
=>
T*m*t*

Exercise 8.x.2