Home
Aptitude
Categories


Home » Python » Python programs

Python | Extend a list using + Operator



Here, we are going to learn how to extend a list by using + operator in python programming language?
Submitted by IncludeHelp, on November 30, 2018

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.

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] 





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.