List Replace¶
You are required to deliver the following function in the module list_replace (file list_replace.py):
- list_replace(Ls, c1, c2)¶
such that
For example:
>>> L = ['abba', 'Adela', 'ell ella allaell', 'La Lola'] >>> n = list_replace(L, 'a', 'o') >>> n == 8 and L == ['obbo', 'Adelo', 'ell ello olloell', 'Lo Lolo'] True >>> L = ['abba', 'Adela', 'bubu', 'ell ella allaell', 'La Lola'] >>> n = list_replace(L, 'a', 'o') >>> n == 3 and L == ['obbo', 'Adelo', 'bubu', 'ell ella allaell', 'La Lola'] True >>> L = ['abba', 'Adela', 'ell ella allaell', 'La Lola'] >>> n = list_replace(L, 'e', 'i') >>> n == 0 and L == ['abba', 'Adela', 'ell ella allaell', 'La Lola'] True
Doctests are available in the list_replace.test file.