2

I need my code to take 2 inputs, a string and a second string. In other words the first string is a sentence of some sort and the second string is just a few letters to be removed from the entire sentence. Example:

remove("This is as it is.", "is") == 'Th  as it .'

So far I have:

def remove(word, reword):
    s = set(reword)
    return (x for x in word if x not in s)

remove("This is as it is.", "is")
print(word)
Chris
  • 27,139
  • 3
  • 23
  • 44
Lamar
  • 207
  • 2
  • 9

1 Answers1

4

You can use the replace function for this.

def remove(word, reword):
    return word.replace(reword, '')

word = remove("This is as it is.", "is")
print(word)
Rusty Robot
  • 1,525
  • 2
  • 12
  • 28