Question on Joining of list
SUBHABRATA
subhabrata.iisc at hotmail.com
Fri Jul 18 06:06:35 EDT 2008
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_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_line[pos]
> print first_char
> elif pos < 0:
> missing_word = word
> print "It is not found"
> print missing_word
> else:
> print "Error"
> s = first_char + " " + missing_word
> print s
>
> try2(1)
>
> Do you recognise your code? With that jumpstart you should find the error in
> no time ;)
>
> > 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?
>
> Yes, use meaningful variables. They won't make your code magically correct
> but will make it a lot easier to pinpoint mistakes and false assumptions --
> for you and others.
>
> Peter
More information about the Python-list
mailing list