Python Extend a list using + Operator

Here, we will figure out how to broaden a list by utilizing + administrator in a python programming language?

Since, work annex() is utilized to embed the components in the list, that we have neglected before. There is another way, we can utilize “+” administrator to affix the components in the list.

Program:

# declaring a list with some of the elements
list1 = [10, 20, 30, 40, 50]
# printing the list
print(list1)

# inserting the elements in list
list1 += [60]
list1 += [70, 80]

# print the updated list
print(list1)

Output:

[10, 20, 30, 40, 50] 
[10, 20, 30, 40, 50, 60, 70, 80] 

Leave a Comment

error: Alert: Content is protected!!