test_str = 'Python for engineers,The complete solution for python programs'
print("The original string is : " + str(test_str))
word_list = ["for", 'The', 'solution']
repl_wrd = 'hai'
res = ' '.join([repl_wrd if idx in word_list else idx for idx in test_str.split()])
print("String after multiple replace : " + str(res))
No comments:
Post a Comment