Question about counting

Hi there!

When you are using the variable “count” how do you start an expression at a different number?? For example if you had the sequence 4, 19, 34, 49, 64, 79, …how would you start the expression at 4?


1 Like

Hello @sofiatosello30296837, welcome to the forums! If there is a specific pattern, like every number divisible by 5, starting from 3, you could use an if to print, using a rule as logic:

for i in range(3, 60):#creating the loop 
  if i % 5 == 0:#checking to see if the number matches a pattern
    print(i)#printing the number if it does

If you just wanted to skip, you could make use of range start, stop, step’ capability:

for count in range(0, 10, 2):#ranges from 0-10, only counting every second number



Here is some reading on the matter.

I hope this helps!