Reputation: 103
I have this list:
scores = [
('WillyCaballero', '2'),
('Angeleri', '2'),
('Antunes', '2'),
('FlavioFerreira', '2'),
('Camacho', '2'),
('SamuGarc\xc3\xada', '2'),
('I\xc3\xb1igoMart\xc3\xadnez', '2'),
('Jos\xc3\xa9\xc3\x81ngel', '6')
...
]
How to store in one str variable and output like this format?:
Willy Caballero 2
Angeleri 2
Antunes 2
...
Upvotes: 3
Views: 98
Reputation: 5207
I would do this;
scoresList = ''
for score in scores:
scoresList += ' '.join(score) + '\n'
#end loop
Upvotes: 0
Reputation: 9828
Edited
>>> out = map(' '.join, p) >>> for i in out: ... print i ... WillyCaballero 2 Angeleri 2 Antunes 2 >>>
Upvotes: 0
Reputation: 34047
Using str.join
, join elements with whitespace
first and then with '\n'
In [25]: print '\n'.join(' '.join(s) for s in scores)
Willy Caballero 2
Angeleri 2
Antunes 2
Flavio Ferreira 2
...
Upvotes: 6