list.extend and list comprehension

后端 未结 6 1799
北恋
北恋 2020-12-10 01:05

When I need to add several identical items to the list I use list.extend:

a = [\'a\', \'b\', \'c\']
a.extend([\'d\']*3)

Result



        
6条回答
提交回复
热议问题