python list extend example
Example 1: extend a list python
list1 = [1,2,3,4,5]
list1.extend([6,7,8])
print(list1)
Example 2: list.extend
languages = ['French', 'English']
languages1 = ['Spanish', 'Portuguese']
languages.extend(languages1)
print('Languages List:', languages)
Example 3: extend in list python
subjects=["Maths","Science","Arts","Commerce"]
subjects_2=["Artificial intelligence","Statistics"]
subjects.extend(subjects_2)
print(subjects)
Example 4: what is the use of extend in python
The extend() method adds the specified list elements (or any iterable) to the end of the current list.