Important Notice:

Course Content
List Manipulation in Python (Chapter-7) M3-R5
About Lesson
Joining Lists:-

      Joining list का अर्थ दो लिस्ट को concatenate (add) करना होता है। + operator का use करके दो लिस्ट को आपस में जोड़कर एक नई लिस्ट बना सकते हैं।

x=[10,20,30]

y=[100,150,200]

c=x+y

print(c)

# [10, 20, 30, 100, 150, 200]

x=[10,20,30]

y=[‘apple’,’banana’,’mango’]

c=x+y

print(c)

# [10, 20, 30, ‘apple’, ‘banana’, ‘mango’]

Note:- दो लिस्ट को concatenate करने के लिए + operator के दोनों argument list type के होने चाहिए।

x=[10,20,30]

y=2

print(x+y)

# TypeError: can only concatenate list (not “int”) to list

 

Joining Lists:-

      Joining list means to concatenate (add) two lists. By using + operator, you can create a new list by joining two lists together.

x=[10,20,30]

y=[100,150,200]

c=x+y

print(c)

# [10, 20, 30, 100, 150, 200]

x=[10,20,30]

y=[‘apple’,’banana’,’mango’]

c=x+y

print(c)

# [10, 20, 30, ‘apple’, ‘banana’, ‘mango’]

Note:- To concatenate two lists, both the arguments of + operator must be of list type.

x=[10,20,30]

y=2

print(x+y)

# TypeError: can only concatenate list (not “int”) to list

error: Content is protected !!