How to remove specific substring from a set of strings in Python

1 Answer

0 votes
st = {'pythonxyz','xyzphp','xyz','xyzxyz','java','c++xyz'}

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

print(st)




'''
run:

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

'''

 



answered Feb 5, 2021 by avibootz
...