What is the second type of loop in Python?
1Times asked
Jul 2026Last seen
Jul 2026First seen
💡 Model Answer
Python has two primary loop constructs: the for loop and the while loop. The for loop iterates over items of a sequence (list, tuple, string, etc.) and is considered the first type. The second type is the while loop, which repeatedly executes a block of code as long as a given condition remains true. Example:
python
# while loop example
count = 0
while count < 5:
print(count)
count += 1The while loop is useful when the number of iterations is not known beforehand and depends on runtime conditions.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500