Actually, since you want to keep the missing words apart from the found ones, it's not necessary to do that. Using "first_char" and "missing_word" (quoting Peter's code) as lists instead of strings comes to mind, then you can join both lists into a string once the code exits the for loop.
Cheers, Quentin On Fri, Jul 18, 2008 at 12:34 PM, Subhabrata Banerjee < [EMAIL PROTECTED]> wrote: > Dear Quentin, > That's true but where to place, if I use it after elif it is not giving > result but if I give in after for there is no use of iteration. > I'm thinking to use a3.find(s) whichever not availiable to split and > iterate and join with s. > Best Regards, > Subhabrata. > > > ------------------------------ > > Date: Fri, 18 Jul 2008 12:11:00 +0200 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Re: Question on Joining of list > > > > In that case, the line 's=a5+" "+a6' should be inside the for loop (and > slightly modified to concatenate the results) > > Cheers, > Quentin > > On Fri, Jul 18, 2008 at 12:00 PM, SUBHABRATA <[EMAIL PROTECTED]> > wrote: > > Sorry if I didn't say that. > The input is a string "Petrol Helium Heaven Sky" > Now, in a3 it is "God Goddess Heaven Sky" is there, > it is matching Heaven and Sky but not Petrol and Helium as they are > not in a3. > Now, as per the code it is giving me an output "S" of "Sky" and > "Helium" > But I was looking for an output of "H S Petrol Helium" and not "S > Helium" meaning all the values of a5 and a6 will be concatenated in s. > Best Regards, > Subhabrata.. > > Marc 'BlackJack' Rintsch wrote: > > On Fri, 18 Jul 2008 01:31:59 -0700, SUBHABRATA wrote: > > > > > def try2(n): > > > a1=raw_input("PRINT A STRING:") > > > a2=a1.split() > > > a3="God Godess Heaven Sky" > > > for x in a2: > > > a4=a3.find(x) > > > if a4>-1: > > > a5=a3[a4] > > > print a5 > > > elif a4<0: > > > a6=x > > > print "It is not found" > > > print a6 > > > else: > > > print "Error" > > > s=a5+" "+a6 > > > print s > > > > > > Here, if I put a string like: > > > Petrol Helium Heaven Sky > > > In s it is giving me S Helium > > > But I am looking for an output of a5 and a6 concatenating all its > > > values not the last ones. Can you suggest me any help? Am I missing > > > any minor point? > > > > Maybe you should describe what the input looks like and what output you > > want to have and how the input and output are connected. In words, not > in > > not very clear code with "numbered names". That's a silly idea and makes > > understanding the code very hard. Please use meaningful names! > > > > Ciao, > > Marc 'BlackJack' Rintsch > -- > http://mail.python.org/mailman/listinfo/python-list > > > > ------------------------------ > This is your window into tinsel town. Keep abreast with the latest movie > releases, star shockers and juicy gossip. Try > it!<http://entertainment.in.msn.com/> >
-- http://mail.python.org/mailman/listinfo/python-list