Python - Iterate through list without using the increment variable Last Updated : 22 Jun, 2021 Comments Improve Suggest changes Like Article Like Report Python Lists is much like flexible size arrays, declared in other languages like vector in C++, array list in Java, etc. Lists are heterogeneous, making it the most effective feature in Python. Lists are mutable, and hence can be modified even after they have been formed. The most common approach is to iterate through a list using the increment variable i: Python3 # Initializing the list List = ["Geeks", 4, 'Geeks!'] # Using index variable to access # each element of the list for i in range(len(List)): print(List[i], end=" ") Output: Geeks 4 Geeks! This is the most common practice where index variable i is used for accessing each element of the list using only the index of that element in that list. However, there are various ways to iterate through a list without using the index variable. Below are some methods to Iterate through a list without using the index variable: Method 1: Explicitly iterating through the list using a common variable for each element rather than the index. Python3 # Initializing the list List = ["Geeks", 4, 'Geeks!'] # Using a common variable to access # each element of the list for ele in List: print(ele, end=" ") Output: Geeks 4 Geeks! Method 2: The enumerate() method adds a counter to the list and returns it in a form of enumerate object which can be used to access elements of the list Python3 # Initializing the list List = ["Geeks", 4, 'Geeks!'] # Using enumerate() for ele in enumerate(List): print(ele[1], end=" ") Output: Geeks 4 Geeks! Method 3: Using the nditer() method in numpy to iterate over a list after converting them into an array. Python3 # Importing required modules import numpy # Initializing the list List = ["Geeks", 4, 'Geeks!'] # Converting to array Array = numpy.array(List) # Using enumerate for ele in numpy.nditer(Array): print(ele, end=" ") Output: Geeks 4 Geeks! Comment More infoAdvertise with us Next Article Python - Iterate through list without using the increment variable riturajsaha Follow Improve Article Tags : Python python-basics Practice Tags : python Similar Reads How to iterate through list of tuples in Python In Python, a list of tuples is a common data structure used to store paired or grouped data. Iterating through this type of list involves accessing each tuple one by one and sometimes the elements within the tuple. Python provides several efficient and versatile ways to do this. Letâs explore these 2 min read Python | Set 3 (Strings, Lists, Tuples, Iterations) In the previous article, we read about the basics of Python. Now, we continue with some more python concepts. Strings in Python: A string is a sequence of characters that can be a combination of letters, numbers, and special characters. It can be declared in python by using single quotes, double quo 3 min read Generate Successive Element Difference List - Python The task is to generate a list of successive element differences, where we calculate the difference between each consecutive pair of elements in a list. For each pair, we subtract the previous element from the next element and create a new list of these differences. This process allows us to see how 3 min read Sort a list in Python without sort Function Python Lists are a type of data structure that is mutable in nature. This means that we can modify the elements in the list. We can sort a list in Python using the inbuilt list sort() function. But in this article, we will learn how we can sort a list in a particular order without using the list sor 3 min read Use enumerate() and zip() together in Python In Python, zip() combines multiple iterables into tuples, pairing elements at the same index, while enumerate() adds a counter to an iterable, allowing us to track the index. By combining both, we can iterate over multiple sequences simultaneously while keeping track of the index, which is useful wh 4 min read Ways to increment Iterator from inside the For loop in Python For loops, in general, are used for sequential traversal. It falls under the category of definite iteration. Definite iterations mean the number of repetitions is specified explicitly in advance. But have you ever wondered, what happens, if you try to increment the value of the iterator from inside 2 min read Python - Count the elements in a list until an element is a Tuple The problem involves a list of elements, we need to count how many elements appear before the first occurrence of a tuple. If no tuple is found in the list, return the total number of elements in the list. To solve this, initialize a counter and use a while loop to iterate through the list, checking 2 min read Appending Item to Lists of list using List Comprehension | Python If you are a Python user, you would know that in Python, we can use the append() method to add an item to an existing list. This list may already contain other items or be empty. Further, the item to be added can simply be a number a character, or even an entire tuple or list. However, if you are tr 5 min read Python | range() does not return an iterator range() : Python range function generates a list of numbers which are generally used in many situation for iteration as in for loop or in many other cases. In python range objects are not iterators. range is a class of a list of immutable objects. The iteration behavior of range is similar to iterat 2 min read How to Remove Item from a List in Python Lists in Python have various built-in methods to remove items such as remove, pop, del and clear methods. Removing elements from a list can be done in various ways depending on whether we want to remove based on the value of the element or index.The simplest way to remove an element from a list by i 3 min read Like