In this example, you will learn how to append a list to a list in Python.
Append List to List Python Program Example
The following Python program will create a fruit list and a vegetable list; then, it will append the fruit list to the vegetable list.
# fruits list fruits = ['apple', 'grapes', 'banana'] # list of vegetables vegetables = ['carrot', 'gabbage'] # appending fruit list to the vegetable list fruits.append(vegetables) print('Updated fruit and vegetable list: ', fruits)
Updated fruit and vegetable list: ['apple', 'grapes', 'banana', ['carrot', 'gabbage']]