blah = [ [1,2,3], [1,3,2] ] for bla in blah: print ' '.join(map(str, bla))
It is worth noting that map bit old-fashioned and better written as a generator or list-comp depending on requirements. This also has the advantage of being portable across Python 2.x and 3.x, as it will generate a list at 2.x, remaining lazy at 3.x
So, above it would be written (using a generator expression) as:
for bla in blah: print ' '.join(str(n) for n in bla)
Or using string formatting:
for bla in blah: print '{} {} {}'.format(*bla)
Jon clements
source share