get it on google playCreated with Sketch.
Python> For loop

For loop

To create a for loop like this, we add the for keyword, a variable like i, the word in, and finally range():

for i in range():

In a for loop we can specify how many times we'd like our loop to run with the range() statement.

for i in range(5):
 print("Happy birthday to you!")

Adding a number like 6, inside range() means it'll loop over the code block 6 times, from 0 until 5.

for i in range(6):
  print(i)

The variable before in, in this case, i, is the counter variable. It counts what repetition of the loop we're currently on.

for i in range(3):
  print(i)
  print("For loops are great!")
TRY IT ON THE APP