We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Python
  3. Introduction
  4. Loops
  5. Tutorial

Loops

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial
  • Tutorial

Loops are control structures that iterate over a range to perform a certain task.

There are two kinds of loops in Python.

A for loop:

for i in range(0, 5):
    print i

And a while loop:

i = 0
while i < 5:
    print i
    i += 1

Note Be careful about indentation in Python. Read more

Here, the term range(0,5) returns a list of integers from to : .

tutorial details


Need Help?


View discussions
View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature