Append two values to list Python
Ngày đăng:
15/12/2021
Trả lời:
0
Lượt xem:
36
Show append two values list in python code exampleExample 1: append two items to listmy_list = ['a'] # You can use list.append(value) to append a single value: my_list.append('b') # my_list should look like ['a','b'] # and list.extend(iterable) to append multiple values. my_list.extend(('b','c')) # my_list should look like ['a','b','c']Example 2: append two list of number to one pythonlistone = [1,2,3] listtwo = [4,5,6] mergedlist = [] mergedlist.extend(listone) mergedlist.extend(listtwo) |