Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unpack a list of lists?

In Python 3 I'm trying to unpack a list of lists:

members = [['3', '5', '5', '20', 'D'], ['2', '2', '2', '30', 'C']]

I want it to print in the format of

3 5 5 20 D
2 2 2 30 C

I've tried using print (' '.join(members)), but I keep getting the error:

TypeError: sequence item 0: expected str instance, list found
like image 840
Aus Avatar asked Dec 04 '22 00:12

Aus


1 Answers

members = [['3', '5', '5', '20', 'D'], ['2', '2', '2', '30', 'C']]
for item in members:
    print ' '.join(item)
like image 138
Sushant Avatar answered Dec 06 '22 13:12

Sushant