KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What is significance of range() function in a for loop.

Python Control Flow

1 Like

Answer

The range() function is a built-in function in Python which is used with the for loop to generate a sequence of integer numbers. It plays a significant role in defining the iteration limit of the for loop.

The range() function takes three parameters — initial value, stop value and update. The for loop iterates over the sequence generated by range() and executes the loop body for each value in the sequence. This makes the for loop simple, concise and easy to control.

Answered By

3 Likes


Related Questions