I was wondering if there was a method or way to return letters not in a string.
Meaning: Let's say I have the word "testing". "ing" in "testing" returns true but I want to return the letters in "testing" that are NOT in "ing" --- "test"
My plan was to go in this direction: But clearly it's wrong and I've been stuck on this for a while.
str = "testing"
cmpr = "ing"
if cmpr in str
return *letters* not cmpr in string
output = "test"
EDIT Better example: (where the letters do not appear in a row)
str = "testing"
cmpr = "tet"
str.replace(cmpr, '', 1) ----> I want it to return "sing" but it still returns "testing"
Can someone please help me solve this?
cmpr = 'ab'andstr = 'ababac'? Do you want'abac','ac','c', or something else? (Also, don't name your stringsstr, or when you try to callstr(something), you'll get a weird TypeError.)str.replace(cmpr, '', 1)to only replace the first occurrence.