How to start a for loop at 1 - Python Last Updated : 02 Dec, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Python for loops range typically starts at 0. However, there are cases where starting the loop at 1 is more intuitive or necessary such as when dealing with 1-based indexing in mathematics or user-facing applications.Let's see some methods to start a for loop at 1 in Python.Using range() with a Start Parameterrange() function allows us to specify a start, stop, and step. By default, it starts at 0 but we can specify 1 as the starting point. Python # Loop starting at 1 for i in range(1, 6): # Loop from 1 to 5 print("Current number:", i) The range(1, 6) specifies a start of 1 and goes up to 5 (excluding 6 as range is non-inclusive), this is the simplest and most common way to start a loop at 1.Let's explore some other methods to start a for loop at 1.Table of ContentUsing a List or Sequence Starting at 1Using an Enumerated Loop Starting at 1Manually Incrementing a VariableUsing a List or Sequence Starting at 1If we have a predefined sequence such as a list starting at 1 then we can iterate directly over it. Python # Predefined list numbers = [1, 2, 3, 4, 5] for num in numbers: print("Current number:", num) In this example, the list numbers starts at 1 so the loop iterates directly over the elements without needing range.Using Enumerated Loop Starting at 1If we are iterating over a collection but need an index that starts at 1 the enumerate() function is useful. It has an optional start parameter to specify the starting index. Python # List of items items = ["apple", "banana", "cherry"] for idx, item in enumerate(items, start=1): print(f"Item {idx}: {item}") enumerate(items, start=1) provides an index starting at 1 while iterating over the list.Manually Incrementing a VariableIn scenarios where a loop inherently starts at 0 we can initialize a counter variable at 1 and increment it manually. Python # Initialize counter start = 1 for _ in range(5): # Loop 5 times print("Current number:", start) start += 1 The start variable begins at 1 and is manually incremented in each iteration Comment More infoAdvertise with us Next Article How to skip Iterations in For Loop - Python K khushidg6jy Follow Improve Article Tags : Python Python Programs python Practice Tags : pythonpython Similar Reads How to start enumerate from 1 in Python ? enumerate() functions allows to iterate over an iterable (like List, tuples) and keeps the track of index at each item. By default, enumerate starts counting from 0 but you can change the starting index to start from 1. By Using start=1 in enumerateUsing enumerate(start=1) is most recommended method 2 min read How to Check End of For Loop in Python In Python, we often use loops to iterate over a collection like list or string. But sometimes, we may want to know when the loop has reached its end. There are different ways to check for the end of a for loop. Let's go through some simple methods to do this.Using else with For Loop (Most Efficient) 2 min read How to skip Iterations in For Loop - Python Loops are generally used to repeat the tasks. Sometimes, we may want to skip certain steps in the loop. We can do this easily with the continue statement. This article explains how to skip iterations in a for loop.In a for loop, you can use continue to skip a specific iteration when a condition is t 2 min read How to Input a List in Python using For Loop Using a for loop to take list input is a simple and common method. It allows users to enter multiple values one by one, storing them in a list. This approach is flexible and works well when the number of inputs is known in advance.Letâs start with a basic way to input a list using a for loop in Pyth 2 min read How to Emulate a Do-while loop in Python? We have given a list of strings and we need to emulate the list of strings using the Do-while loop and print the result. In this article, we will take a list of strings and then emulate it using a Do-while loop. Do while loop is a type of control looping statement that can run any statement until th 3 min read How to Repeat a String in Python? Repeating a string is a simple task in Python. We can create multiple copies of a string by using built-in features. This is useful when we need to repeat a word, phrase, or any other string a specific number of times. Using Multiplication Operator (*):Using Multiplication operator (*) is the simple 2 min read Like