Python – Join Lists

1. What Does โ€œJoin Listsโ€ Mean?

Joining lists means combining two or more lists into one list.

This is useful when:

  • You have data in different lists

  • You want them together in one list

2. Join Lists Using + Operator

The easiest way to join lists is using +.

Example

list1 = [1, 2, 3]
list2 = [4, 5, 6]

new_list = list1 + list2
print(new_list)

Output:

[1, 2, 3, 4, 5, 6]

๐Ÿ‘‰ This creates a new list.

3. Join Lists Using extend()

extend() adds items of one list to the end of another list.

Example

fruits = ["apple", "banana"]
more_fruits = ["orange", "grape"]

fruits.extend(more_fruits)
print(fruits)

๐Ÿ‘‰ This changes the first list.

4. Join Lists Using Loop

You can join lists manually using a loop.

Example

list1 = [10, 20]
list2 = [30, 40]

for item in list2:
list1.append(item)

print(list1)

5. Join Multiple Lists

Example

a = [1, 2]
b = [3, 4]
c = [5, 6]

result = a + b + c
print(result)

6. Join Lists with Different Data Types

Lists can store mixed data.

Example

numbers = [1, 2]
words = ["one", "two"]

joined = numbers + words
print(joined)

7. Common Beginner Mistakes

โŒ Using append() Instead of extend()

list1.append(list2)

Result:

[1, 2, [3, 4]]

โœ” Correct:

list1.extend(list2)

โŒ Expecting extend() to return list

new_list = list1.extend(list2)

โŒ extend() returns None.

8. Simple Practice Examples

Example 1: Join Student Names

class1 = ["Amit", "Ravi"]
class2 = ["Sita", "Gita"]

students = class1 + class2
print(students)

Example 2: Join Numbers

nums1 = [1, 2]
nums2 = [3, 4]

nums1.extend(nums2)
print(nums1)

Example 3: Join Using Loop

a = ["red"]
b = ["blue", "green"]

for color in b:
a.append(color)

print(a)

9. Summary (Join Lists)

โœ” + creates new list
โœ” extend() adds to existing list
โœ” Loop method also works
โœ” Avoid append() for joining lists

๐Ÿ“˜ Perfect for Beginner eBook

This chapter is ideal for:

  • Python beginner books

  • School & college students

  • Self-learners

If you want next, I can write:

  • Tuple Basics

  • Set Basics

  • Dictionary Basics

  • List Exercises

  • MCQs with answers

Just tell me ๐Ÿ˜Š

You may also like...