Another modify task, and this time the counter’s value ends up in the output, so the range has to be exactly right.
The editor starts you off with a loop that numbers its own lines:
for counter in range(1, 11, 1):
print("This is line " + str(counter))
Run it first. The counter takes the values 1 to 10, and each line says which one it is on.
Change the program so that it prints the even numbers from 2 to 8, each one described as an even number.
range(...) so that the counter takes the values 2, 4, 6 and 8.
The third number inside the brackets is the step.print so that each line reads as shown below.print: the
numbers must come from the counter, not be typed in by hand.Four lines, where NUMBER is the value of the counter on that time round:
NUMBER is an even number.
Output:
2 is an even number.
4 is an even number.
6 is an even number.
8 is an even number.
The full stop at the end of each line is part of it.
Make sure that you check for the following things:
str() before it is joined onto text with a
+.is comes from inside the string.