Question on Joining of list

SUBHABRATA subhabrata.iisc at hotmail.com
Fri Jul 18 04:31:59 EDT 2008


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 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?
Best Regards,
Subhabrata.



More information about the Python-list mailing list