Which of the following is a valid for loop in Python?
A. for(i=0; i < n; i++)
B. for i in range(0,5):
C. for i in range(0,5)
D. for i in range(5) have
Answers
Answered by
14
B. for i in range(0,5):
Answered by
0
for I in range(0,5): is valid for loop in Python
Python for-in loop
- Iterating through a sequence in Python is done with a for-in loop (that is either a list, a tuple, a dictionary, a set, or a string). It is used for traversal in sequential order.
- Using the range() method in the for-in loop, we can loop through a set of statements a defined number of times.
- The range() function returns a number series that starts at 0 and advances by 1 (by default) until it reaches a specified value.
Similar questions