7.6 / 10 123... ✧

def remove_all_from_string(word, letter): return word.replace(letter, "") Use code with caution. Copied to clipboard

The prompt likely refers to from the CodeHS Python curriculum. This exercise requires you to write a function that removes every instance of a specific "letter" (or substring) from a given word. Correct Python Implementation 7.6 / 10 123...

While the CodeHS exercise often requires the manual loop approach above, the simplest way to do this in standard Python is using the .replace() method: def remove_all_from_string(word, letter): return word

: If letter is an empty string, the loop would run forever; we return the original word immediately. letter): return word.replace(letter