Just a quick one
Ian J Cottee
ian at cottee.org
Thu Aug 26 07:24:52 CEST 2004
M. Clift wrote:
> At the risk of looking stupid would someone mind showing me how this is done
> in this case. I can't remove the brackets from (('Bob', 'Mary'), ('Spam',
> 'chips')) to give(('Bob', 'Mary', 'Spam', 'chips')) . From what Phil and Sm
> said I thought it would be easy. I've tried using list( ). I've had a go at
> referencing the individual elements...
Noodle around with IDLE (if using windows it should be in your python
group). It's a great way to play with this stuff.
>>> stuff = (('Bob', 'Mary'), ('Spam', 'chips'))
Hmmm - what is stuff?
I see. How big is it?
Ah ... so ...
So in that case
>>> morestuff = stuff+stuff
('Bob', 'Mary', 'Spam', 'chips')
>>> evenmorestuff = list(morestuff)
['Bob', 'Mary', 'Spam', 'chips']
Well - it got rid of your brackets. But was it what you wanted? Maybe
you actually now want.
>>> stringstuff = ', '.join(morestuff)
'Bob, Mary, Spam, chips'
Hmmm - getting quite stuff'y in here isn't it? :)
More information about the Python-list