This website collects cookies to deliver better user experience
calling add_dots("test") should return the string "t.e.s.t".
Then, below the add_dots function,
write another function named remove_dots that removes all dots from a string.
For example
calling remove_dots("t.e.s.t") should return "test".
If both functions are correct,
calling remove_dots(add_dots(string)) should return back the original string for any string.
The input while building up a result string that is initially empty.
The remove_dots function is similar.
Either use the string replace method or manually loop over the letters,
keeping ones that aren't ".".
def add_dots(string): new_string = ".".join(string) return new_string print(add_dots("test")) def remove_dots(string): new_string = string result = new_string.replace(".", "") return result print(remove_dots("t.e.s.t")) print(remove_dots(add_dots("tito")))
def add_dots(s): out = "" for letter in s: out += letter + "." return out[:-1] # -> do not show the lest dot def remove_dots(s): out = "" for letter in s: if letter != ".": out += letter return out
def add_dots(s): return ".".join(s) def remove_dots(s): return s.replace(".", "")
33
0