Drop links or images here to add them to the editor.

In a modify task you take code that already works and adapt it so that it does something else.

The editor starts you off with a loop that prints the same message over and over:

message = "This is how you get code to repeat."

for counter in range(1, 10):
    print(message)

Run it first and count the lines. The range runs from 1 up to but not including 10, so the message appears nine times, not ten.

Your task

Change the program so that it outputs the message 20 times instead.

The tests also check your code: the message has to be printed by a for loop with a single print statement.

There is more than one range that gives you 20 repetitions. range(20) counts 0 to 19 and range(1, 21) counts 1 to 20, and since the counter is never printed here, either is fine.

The output

Twenty identical lines, each one reading:

This is how you get code to repeat.

Example

Output:

This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.
This is how you get code to repeat.

The full stop at the end of the message is part of it, so leave it in.

Help! My code doesn't work!

Make sure that you check for the following things:

  • You have counted the lines of output. Nineteen and twenty-one are the two easy mistakes here.
  • The numbers inside range(...) are separated by commas.
  • The stop value is never reached, so range(1, 20) repeats 19 times.
  • The print line is still indented under the for.
  • The message still reads exactly as it did, full stop included.