Re: Question on Joining of list

2008-07-20 Thread SUBHABRATA
Thanx Terry it worked, I was thinking if input_string could be searched from given_string and replaced in the input_string but your one is smarter. And Peter, thanx for trying to teach conventions. But if I write explicit comments, and carry on using my own variables( I can use anything as they are

Re: Question on Joining of list

2008-07-20 Thread MRAB
On Jul 19, 6:34 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Fri, 18 Jul 2008 16:43:35 -0700 (PDT), John Machin > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > The only language I remember that had implicit typing was FORTRAN (GOD > > is real, but JESUS is an i

Re: Question on Joining of list

2008-07-19 Thread ptn
On Jul 18, 6:43 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 18, 11:42 pm, ptn <[EMAIL PROTECTED]> wrote: > [snip] > > >  Remember C, where i, j, > > k are indices, p, q, r are pointers, s, t are strings and x, y, z are > > integers. > > Only by convention (even-K&R-v1 C required explicit de

Re: Question on Joining of list

2008-07-18 Thread John Machin
On Jul 18, 11:42 pm, ptn <[EMAIL PROTECTED]> wrote: [snip] > Remember C, where i, j, > k are indices, p, q, r are pointers, s, t are strings and x, y, z are > integers. Only by convention (even-K&R-v1 C required explicit declarations almost everywhere), and x etc being used for integers is news t

Re: Question on Joining of list

2008-07-18 Thread Terry Reedy
SUBHABRATA 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, > ...I was looking for an output of "H S Petrol Helium" Meaningful names, splitting the target string, and using 'in' makes the code much easier

Re: Question on Joining of list

2008-07-18 Thread ptn
On Jul 18, 5:40 am, SUBHABRATA <[EMAIL PROTECTED]> wrote: > Hi Peter,Peter Otten wrote: > > SUBHABRATA wrote: > > > > Thanx Peter, > > > I would change my variables next time I would post. > > > No, you should use meaningful variable names when you write your code no > > matter whether you plan to

Re: Question on Joining of list

2008-07-18 Thread Quentin Gallet-Gilles
on. > 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

Re: Question on Joining of list

2008-07-18 Thread SUBHABRATA
Hi Peter, Peter Otten wrote: > SUBHABRATA wrote: > > > Thanx Peter, > > I would change my variables next time I would post. > > No, you should use meaningful variable names when you write your code no > matter whether you plan to post it or not. Good You are teaching me something good in life. Than

Re: Question on Joining of list

2008-07-18 Thread Peter Otten
SUBHABRATA wrote: > Thanx Peter, > I would change my variables next time I would post. No, you should use meaningful variable names when you write your code no matter whether you plan to post it or not. > And obviously, > thanx for your solution. I am reviewing it, I was also trying out some >

Re: Question on Joining of list

2008-07-18 Thread SUBHABRATA
Hi Peter, In your code s would print first_char(of the last word)+" "+missing_word(the last word) I was looking all. Best Regards, Subhabrata. SUBHABRATA 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, >

Re: Question on Joining of list

2008-07-18 Thread SUBHABRATA
Thanx Peter, I would change my variables next time I would post. And obviously, thanx for your solution. I am reviewing it, I was also trying out some solutions. Best Regards, Subhabrata. Peter Otten wrote: > SUBHABRATA wrote: > > > I am trying the following code line: > > def try2(n): > user_

Re: Question on Joining of list

2008-07-18 Thread SUBHABRATA
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

Re: Question on Joining of list

2008-07-18 Thread Peter Otten
SUBHABRATA wrote: > I am trying the following code line: def try2(n): user_line = raw_input("PRINT A STRING:") user_words = user_line.split() my_line = "God Godess Heaven Sky" for word in user_words: pos = my_line.find(word) if pos >- 1: first_char = my

Re: Question on Joining of list

2008-07-18 Thread Marc 'BlackJack' Rintsch
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] >

Question on Joining of list

2008-07-18 Thread SUBHABRATA
Dear Group, I am trying the following code line: 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