Continue From the Beginning (Solution)
So, now I can do this using a
for loop. So, I’ll start with that. I’m going to say
for number in range(1)—and here’s a nice popup that tells me that the final step is not included—so I’m going to have to say
(1, 51) to loop from starting to
1 up to
So, it can say
if number % 3 == 0: I need something in here. What this says is that if the number is divisible by three without a remainder, so if there’s no remainder if I divide the number by three, so that means that it’s a multiple of three, then I want to not print it.
So in this case, I need to do something in here, and that’s where I use the loop keyword. I’m going to say
continue, which ends the execution of this specific round of the loop and jumps back to the beginning, goes to the next number basically. And so in this case, if this conditional expression here evaluates to
True, the Python program will use the
continue keyword, and it will not continue to run the
print() statement underneath, which means that it’s not going to print out values for numbers that are divisible by three without a remainder. Let’s try this out.
Become a Member to join the conversation.