num_list_1 = [10, 20, 30, 40]
num_list_2 = [50, 60]
concatenated_list = num_list_1 + num_list_2
print(concatenated_list)
Output:
Example 2: Using the built-in extend() method from List Class
countries1 = ["USA", "Canada", "Mexico"]
countries2 = ["Germany", "France", "Spain"]
countries1.extend(countries2)
concatenated_list = countries1
print(concatenated_list)
Output:
Example 3: Using the built-in append() method from List Class
genres1 = ["Rock", "Pop", "Hip Hop"]
genres2 = ["Jazz", "Country", "Reggae"]
for genre in genres2:
genres1.append(genre)
concatenated_list = genres1
print(concatenated_list)
Example 4: Using the * Operator and List Unpacking
list1 = [1, 2, 3, 4, 5]
list2 = [6, 7]
concatenated_list = [*list1, *list2]
print(concatenated_list)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Python-Programs,
- Program 5: Find Sum of Two Integer Numbers - 1000+ Python Programs
- 34: Traverse a List in Reverse Order - 1000+ Python Programming
- 22: Send Yahoo! Email using smtplib - SMTP protocol client using Python Program
- 35: Python Program to find the System Hostname
- 27: Measure Elapsed Time for a Python Program Execution
- Program 7: Find Difference of Two Numbers - 1000+ Python Programs
- Program 12: Calculate Area and Circumference of Circle - 1000+ Python Programs
- Program 9: Divide Two Numbers - 1000+ Python Programs
- Program 2: Print your name using print() function - 1000+ Python Programs
- 25: How to rename a file using Python Program
- 17: Find Factorial of a Number - 1000+ Python Programs
- Program 6: Find Sum of Two Floating Numbers - 1000+ Python Programs
- 23: Python Programs to concatenate two Lists
- 36: Python Program Convert Hex String to Integer
- 20 - Python - Print Colors for Text in Terminal - 1000+ Python Programs
- Python Program: Use NumPy to generate a random number between 0 and 1
- 32: Python Program to Find Square Root of a Number
- Program 8: Multiply Two Numbers - 1000+ Python Programs
- Program 11: Calculate Percentage - 1000+ Python Programs
- 18: Get Sub List By Slicing a Python List - 1000+ Python Programs
- 28: Program to Lowercase a String in Python
- Program 1: Print Hello World! - 1000+ Python Programs
- 21: Program to Delete File or Folder in Python
- 29: Program to convert Python dict to dataframe
- 33: Python Program to find the current time in India (IST)
More Posts:
- [macOS Sonoma] Python3 - xcode-select: note: No developer tools were found requesting install - Python
- How to Check for Not None in Python Programming - Python
- How to view App Licenses Assigned to You on Windows 365 Account - Windows
- Mac: Change Screenshot Location - MacOS
- SharePoint Designer Workflow error - Coercion Failed: Input cannot be null for this coercion - SharePoint
- [Java] Error: Unmappable character for encoding UTF-8. Save could not be completed. - Java
- Git Commit - Author identity unknown, Please tell me who you are email - Git
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023] - MacOS