Question on List

subhabrata.iisc at hotmail.com subhabrata.iisc at hotmail.com
Fri Jun 27 09:51:53 CEST 2008


Dear All,
I am trying to write the following code:

def try1(n):
	a1="God Godess Borother Sister Family"
	a2=a1.split()
	a3=raw_input("PRINT A WORD")
	a4=a1.find(a3)
	print a4
	a5=[]
	if a4>0:
		a5=a2.index(a3)
		a6=a5+1
		a7=a2[a6]
		print "The new word is"
		print a7
		a8=a5.append(a7)
		print a5
	elif a4<0:
		a11=a3
		print "The word is not availiable in String"
		print a11
		a6=a5.append(a11)
		print a5
	else:
		print "Error"

Now, my question is I like to see a5 or the empty list as appended
with elements. Results I am getting is a5 giving single value like
['God'],['Godess']... but I like to see it as ['God','Godess'...] etc.
Am I going wrong?
Do I have to rethink it in some other way?
If any one can kindly let me know.
Best Regards,
Subhabrata.



More information about the Python-list mailing list