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)
1
  • 1
    use .replace() Commented Mar 2, 2020 at 3:37

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.