Q:

Python | Extend a list using + Operator

0

Since, function append() is used to insert the elements in the list, that we have disused earlier. There is another way, we can use "+" operator to append the elements in the list.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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] 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now