What's the difference between [a] + [b] and [a].extend([b])?
问题 There are 2 ways to merge lists together in Python: ['a', 'b', 'c'] + ['x', 'y', 'z'] ['a', 'b', 'c'].extend(['x', 'y', 'z']) What's the difference between the 2 methods? What's the more Pythonic way of concatenating more than 2 lists? ['a', 'b', 'c'] + [1, 2, 3] + ['x', 'y', 'z'] gucci_list = ['a', 'b', 'c'] gucci_list.extend([1, 2, 3]) gucci_list.extend(['x', 'y', 'z']) How about combining both? ['a', 'b', 'c'].extend([1, 2, 3] + ['x', 'y', 'z']) 回答1: The first statement creates a new list