Reputation: 5371
How do I make the following list:
nested_list = [['dave','dave'],['ian','ian'],['james','james']]
from:
list = ['dave', 'ian', 'james']
Upvotes: 2
Views: 49
Reputation: 18521
nested_list = [[x, x] for x in list]
or, if you don't mind tuples,
nested_list = zip(list, list)
Upvotes: 7