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". Simple replace method may not work. I was trying the following script. import fuzzywuzzy from fuzzywuzzy import fuzz from fuzzywuzzy import process import itertools def sometry(): x1="Hello my name is Richard" x2=x1.split() x3=['Hello/Hi','my','name','is','Richard/P'] list1=[] for i in x2: x4=process.extractOne(i, x3) print x4 x5=x4[0] print x5 x6=[x5 if x==i else x for x in x2] print x6 list1.append(x6) b1=list1 print b1 merged = list(itertools.chain.from_iterable(b1)) merged1=list(set(merged)) print merged1 I am working in Python2.x on MS-Windows. This is a simple practice script so I have not followed style guides. Apology for any indentation error. I am trying if any one of the members may give any idea how may I achieve it. Thanks in Advance. -- https://mail.python.org/mailman/listinfo/python-list