On Sat, 12 Nov 2016 09:29 am, subhabangal...@gmail.com wrote: > I have a string > "Hello my name is Richard" > > I have a list of words as, > ['Hello/Hi','my','name','is','Richard/P'] > > I want to identify the match of 'Hello' and 'Richard' > in list, and replace them with 'Hello/Hi" and 'Richard/P' > respectively. > > The result should look like, > "Hello/Hi my name is Richard/P".
Looks like you want: mystring = "Hello my name is Richard" words = ['Hello/Hi', 'my', 'name', 'is', 'Richard/P'] result = " ".join(words) assert result == "Hello/Hi my name is Richard/P" and mystring is irrelevant. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list