On Thu, 28 Aug 2008 09:13:00 -0700, SUBHABRATA wrote: > import re > def wordchecker1(n): > # INPUTTING STRING > a1=raw_input("PRINT ONE ENGLISH SENTENCE FOR DICTIONARY CHECK:") > #CONVERTING TO LOWER CASE > a2=a1.lower() > #CONVERTING INTO LIST > a3=a2.split() > #DICTIONARY > a4=open("/python25/Changedict3.txt","r") a5=a4.read() > a6=a5.split() > found=[] > not_found=[] > #SEARCHING DICTIONARY > for x in a3: > a7="\n" > a8=a7+x > if a8 in a5: > a9=a5.index(a8) > a10=a5[a9:] > a11=re.search("\xe0.*?\n",a10) > a12=a11.group() > a13=a12[:-1] > found.append(a13) > elif a8 not in a5: > a14=x > not_found.append(a14) > else: > print "Error" > found.extend(not_found) > # THE OUTPUT > print "OUTPUT STRING IS" > a15=(' '.join(found)) > #THE OUTPUT STRING > print a15 > # SPLITTING OUTPUT STRING IN WORDS > a16=a15.split() > #TAKING OUT THE WORD FROM OUTPUT STRING for word in a16: > #MATCHING WITH GIVEN STRING > a17=a2.find(word) > if a17>-1: > print "The word is found in the Source String" > a18=a3.index(word) > a19=a3[a18] > print a19 > #INSERTING IN THE LIST OF TARGET STRING > a20=a16.insert(a18,a19) > print a16 > a21=(" ".join(a16)) > print a21
a1, a2, a2, …, a20? You must be kidding. Please stop numbering names and use *meaningful* names instead! Could you describe them problem better, with sample inputs and expected outputs. There must be a better way that that unreadable mess above. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list