"Write a function named remove_all that accepts" a string and a character as parameters, and removes all occurrences of the character. For example, the call of remove_all("Summer is here!", 'e') should return "Summr is hr!". Do not use the string replace function in your solution.

Respuesta :

Answer:

def remove_all(text, char):

   return ''.join(x for x in text if x not in char )

           

print(remove_all("Summer is here!", 'e'))

Explanation:

- join() method in Python takes all the element in the string and joins them. However, inside the join method, we excluded the elements that equals to char in the text

Otras preguntas