7.6 / 10 123... -
: word[:index] takes everything before the letter, and word[index + len(letter):] takes everything after it. Adding them together effectively "deletes" the unwanted part.
: This method returns the starting index of the first occurrence of letter . If it isn't found, it returns -1 . 7.6 / 10 123...
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 : word[:index] takes everything before the letter, and
: If letter is an empty string, the loop would run forever; we return the original word immediately. the loop would run forever