How to remove N specific substrings from a set of strings in Python

1 Answer

0 votes
st = {'abcpythonxyz','abcxyzphp','xyzabc','abcxyzxyz','java','abcc++xyzabc'}

st = {x.replace('xyz', '').replace('abc', '') for x in st}

print(st)




'''
run:

{'', 'python', 'php', 'java', 'c++'}

'''

 



answered Feb 5, 2021 by avibootz
...