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
  • 29,127
  • 3
  • 28
  • 51
Lamar
  • 217
  • 2
  • 10

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,725
  • 2
  • 13
  • 29