[Tutor] writing list elements into a string

ps python ps_python3 at yahoo.co.in
Thu Dec 15 21:37:09 CET 2005


hi, 
can any one pls. help me on this simple issue.  I keep
forgetting some simple things and they turn out to be
very important later. 

i have a list 'a', and now i want to write all the
elements back in to a string.  'apple is a good fruit'
- getting this back into a string has drained my
brain. 

appreciate your help all. 




>>> a  = ['apple','is','a','good','fruit']
>>> for m in a:
	print m,

	
apple is a good fruit
>>> ab =''
>>> for m in a:
	k = ''.join(m)
	ab.join(k)

'apple'
'is'
'a'
'good'
'fruit'
>>> 



		
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com


More information about the Tutor mailing list