Question on Joining of list

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Jul 18 11:46:11 CEST 2008


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



More information about the Python-list mailing list