Python - Create list of tuples using for loop Last Updated : 18 Apr, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to create a List of Tuples using for loop in Python. Let's suppose we have a list and we want a create a list of tuples from that list where every element of the tuple will contain the list element and its corresponding index. Method 1: Using For loop with append() method Here we will use the for loop along with the append() method. We will iterate through elements of the list and will add a tuple to the resulting list using the append() method. Example: Python3 L = [5, 4, 2, 5, 6, 1] res = [] for i in range(len(L)): res.append((L[i], i)) print("List of Tuples") print(res) OutputList of Tuples [(5, 0), (4, 1), (2, 2), (5, 3), (6, 4), (1, 5)]Method 2: Using For loop with enumerate() method Enumerate() method adds a counter to an iterable and returns it in a form of enumerating object. So we can use this function to create the desired list of tuples. Example: Python3 L = [5, 4, 2, 5, 6, 1] res = [] for index, element in enumerate(L): res.append((element, index)) print("List of Tuples") print(res) OutputList of Tuples [(5, 0), (4, 1), (2, 2), (5, 3), (6, 4), (1, 5)]Method 3: Using zip() function Using Python's zip() function we can create a list of tuples, for that we will require two lists. Step-by-step approach: Firstly, initialize two variables that will hold some values as a list and the other one will hold the indexes of those values as a list.Then use another variable in which we will hold the result of our zip() Operation. Then we need to convert the result of the zip function into a list.We will then print the variable. Below is the implementation of the above approach: Python3 # Defining arr1 arr1 = [5, 4, 2, 5, 6, 1] # Creating the second array which # holds the index values of previous array arr2 = [i for i in range(len(arr1))] # converting the result into list res = list(zip(arr1,arr2)) # printing the result print(res) Output[(5, 0), (4, 1), (2, 2), (5, 3), (6, 4), (1, 5)] Time Complexity - O(min(len(iterable_1), len(iterable_2)))Auxiliary Space - O(n) Comment More infoAdvertise with us Next Article Python - Create list of tuples using for loop A Akanksha_Rai Follow Improve Article Tags : Python Python Programs Blogathon Blogathon-2021 Python List-of-Tuples +1 More Practice Tags : python Similar Reads Python Tuples A tuple in Python is an immutable ordered collection of elements. Tuples are similar to lists, but unlike lists, they cannot be changed after their creation (i.e., they are immutable). Tuples can hold elements of different data types. The main characteristics of tuples are being ordered , heterogene 6 min read Tuple Operations in Python Python Tuple is a collection of objects separated by commas. A tuple is similar to a Python list in terms of indexing, nested objects, and repetition but the main difference between both is Python tuple is immutable, unlike the Python list which is mutable.Python# Note : In case of list, we use squa 7 min read Create a List of Tuples in Python The task of creating a list of tuples in Python involves combining or transforming multiple data elements into a sequence of tuples within a list. Tuples are immutable, making them useful when storing fixed pairs or groups of values, while lists offer flexibility for dynamic collections. For example 3 min read Create a tuple from string and list - Python The task of creating a tuple from a string and a list in Python involves combining elements from both data types into a single tuple. The list elements are added as individual items and the string is treated as a single element within the tuple. For example, given a = ["gfg", "is"] and b = "best", t 3 min read Access front and rear element of Python tuple Sometimes, while working with records, we can have a problem in which we need to access the initial and last data of a particular record. This kind of problem can have application in many domains. Let's discuss some ways in which this problem can be solved. Method #1: Using Access Brackets We can pe 6 min read Python - Element Index in Range Tuples Sometimes, while working with Python data, we can have a problem in which we need to find the element position in continuous equi ranged tuples in list. This problem has applications in many domains including day-day programming and competitive programming. Let's discuss certain ways in which this t 7 min read Unpacking a Tuple in Python Tuple unpacking is a powerful feature in Python that allows you to assign the values of a tuple to multiple variables in a single line. This technique makes your code more readable and efficient. In other words, It is a process where we extract values from a tuple and assign them to variables in a s 2 min read Unpacking Nested Tuples-Python The task of unpacking nested tuples in Python involves iterating through a list of tuples, extracting values from both the outer and inner tuples and restructuring them into a flattened format. For example, a = [(4, (5, 'Gfg')), (7, (8, 6))] becomes [(4, 5, 'Gfg'), (7, 8, 6)].Using list comprehensio 3 min read Python | Slice String from Tuple ranges Sometimes, while working with data, we can have a problem in which we need to perform the removal from strings depending on specified substring ranges. Let's discuss certain ways in which this task can be performed. Method #1: Using loop + list slicing: This is the brute force task to perform this t 3 min read Python - Clearing a tuple Sometimes, while working with Records data, we can have a problem in which we may require to perform clearing of data records. Tuples, being immutable cannot be modified and hence makes this job tough. Let's discuss certain ways in which this task can be performed. Method #1 : Using list() + clear() 4 min read Like