How to Concatenate Two Lists Index Wise in Python Last Updated : 20 Feb, 2025 Comments Improve Suggest changes Like Article Like Report Concatenating two lists index-wise means combining corresponding elements from both lists into a single element, typically a string, at each index . For example, given two lists like a = ["gf", "i", "be"] and b = ["g", "s", "st"], the task is to concatenate each element from a with the corresponding element from b. The result would be a list of concatenated strings: ['gfg', 'is', 'best'].Using list comprehensionList comprehension is one of the most efficient and Pythonic ways to concatenate lists index-wise. It allows you to create a new list in a concise and readable way while iterating over the lists. Python # Input Lists a = ["gf", "i", "be"] b = ["g", "s", "st"] ans = [a[i] + b[i] for i in range(min(len(a), len(b)))] print(ans) Output['gfg', 'is', 'best'] Explanation:a[i] + b[i] concatenates the elements at index i of both lists.min(len(a), len(b)) ensures that the loop only runs for the indices available in both lists, preventing errors when lists have unequal lengths.Table of ContentUsing zip()Using map()Using for loopUsing zip()zip() pairs elements from two or more iterables. This is ideal for concatenating lists index-wise because it automatically pairs elements from both lists and allows for easy element-wise operations. Python # Input Lists a = ["gf", "i", "be"] b = ["g", "s", "st"] ans = [x + y for x, y in zip(a, b)] print(ans) Output['gfg', 'is', 'best'] Explanation:zip(a, b) pairs each element from a and b together as tuples, e.g., ('gf', 'g'), ('i', 's'), etc.list comprehension then concatenates these paired elements.Using map()map() applies a function to every item of an iterable. We can use map() to concatenate two lists index-wise by applying a lambda function to the pairs of elements from both lists. Python # Input Lists a = ["gf", "i", "be"] b = ["g", "s", "st"] ans = list(map(lambda x, y: x + y, a, b)) print(ans) Output['gfg', 'is', 'best'] Explanation:map(lambda x, y: x + y, a, b) applies the lambda function to each pair of elements from a and b, effectively concatenating them.list() function converts the map object into a list.Using for loopA regular for loop is the most basic method to concatenate two lists index-wise. While it’s not as optimized as the other methods, it is still a widely used technique and can be useful in specific scenarios where you want full control over the iteration process. Python # Input Lists a = ["gf", "i", "be"] b = ["g", "s", "st"] ans = [] for i in range(min(len(a), len(b))): ans.append(a[i] + b[i]) print(ans) Output['gfg', 'is', 'best'] Explanation:loop iterates over the indices of the shorter list (min(len(a), len(b)) ensures safe iteration).a[i] + b[i] concatenates the elements at index i from both lists and appends them to ans . Comment More infoAdvertise with us Next Article How to Concatenate Two Lists Index Wise in Python V vishuvaishnav3001 Follow Improve Article Tags : Python python-list Practice Tags : pythonpython-list Similar Reads How to add Elements to a List in Python In Python, lists are dynamic which means that they allow further adding elements unlike many other languages. In this article, we are going to explore different methods to add elements in a list. For example, let's add an element in the list using append() method:Pythona = [1, 2, 3] a.append(4) prin 2 min read Convert Two Lists into a Dictionary - Python We are given two lists, we need to convert both of the list into dictionary. For example we are given two lists a = ["name", "age", "city"], b = ["Geeks", 30,"Delhi"], we need to convert these two list into a form of dictionary so that the output should be like {'name': 'Geeks', 'age': 30, 'city': ' 3 min read Ways to Iterate Tuple List of Lists - Python In this article we will explore different methods to iterate through a tuple list of lists in Python and flatten the list into a single list. Basically, a tuple list of lists refers to a list where each element is a tuple containing sublists and the goal is to access all elements in a way that combi 3 min read How to Access Index using for Loop - Python When iterating through a list, string, or array in Python, it's often useful to access both the element and its index at the same time. Python offers several simple ways to achieve this within a for loop. In this article, we'll explore different methods to access indices while looping over a sequenc 2 min read Element-wise concatenation of two NumPy arrays of string In this article, we will discuss how to concatenate element-wise two arrays of string Example : Input : A = ['Akash', 'Ayush', 'Diksha', 'Radhika'] B = ['Kumar', 'Sharma', 'Tewari', 'Pegowal'] Output : A + B = [AkashKumar, AyushSharma, 'DikshTewari', 'RadhikaPegowal'] We will be using the numpy.cha 2 min read How to Use cbind in Python? In Python, the equivalent function cbind in R is typically achieved using the concat function from the Pandas library. In this article, we will discuss cbind in Python. We have seen cbind() function in R Programming language to combine specified Vector, Matrix, or DataFrame by columns. But in Python 3 min read Concatenate multiIndex into single index in Pandas Series In this article, we will see how to concatenate multi-index to a single index in Pandas Series. Multi-index refers to having more than one index with the same name. Create a sample series: Python3 # importing pandas module import pandas as pd import numpy as np # Creating series data for address det 3 min read Python | Numpy np.ma.concatenate() method With the help of np.ma.concatenate() method, we can concatenate two arrays with the help of np.ma.concatenate() method. Syntax : np.ma.concatenate([list1, list2]) Return : Return the array after concatenation. Example #1 : In this example we can see that by using np.ma.concatenate() method, we are a 1 min read Python | Extract Combination Mapping in two lists Sometimes, while working with Python lists, we can have a problem in which we have two lists and require to find the all possible mappings possible in all combinations. This can have possible application in mathematical problems. Let's discuss certain way in which this problem can be solved. Method 2 min read Appending to 2D List in Python A 2D list in Python is a list of lists where each sublist can hold elements. Appending to a 2D list involves adding either a new sublist or elements to an existing sublist. The simplest way to append a new sublist to a 2D list is by using the append() method.Pythona = [[1, 2], [3, 4]] # Append a new 2 min read Like