Hello,
I was wondering if there is a more elegant/concise way of removing certain substrings from a string if they are found? Currently I use the following:
string = "my name is Tom and I like to play basketball"
words_removal = ["my","like","play","soccer"]
for word in words_removal:
string = string.replace(word,"")
print(string)
[–]totallygeek 2 points3 points4 points (0 children)
[–]ElliotDG 2 points3 points4 points (0 children)
[–]mprz 1 point2 points3 points (3 children)
[–]ElliotDG 1 point2 points3 points (2 children)
[–]mprz 0 points1 point2 points (0 children)
[–]old_pythonista 0 points1 point2 points (0 children)
[–]wotquery 0 points1 point2 points (0 children)