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 counter loop that prints part of the six times table:

number = 6
counter = 1

while counter < 13:
    print(counter * number)
    counter = counter + 1

Run it first to see what it does. It prints twelve bare numbers, and it is not easy to tell what any of them mean.

Your task

Adapt the code so that the user picks the number, the output explains itself, and the counter goes up in twos.

Leave the counter = 1 line and the while counter < 13: condition exactly as they are.

The output

Each line inside the loop is worded exactly like this, where NUMBER is what the user typed, COUNTER is the value of the counter on that time round, and PRODUCT is the two of them multiplied together:

NUMBER multiplied by COUNTER equals PRODUCT

The counter starts at 1 and goes up in twos while it is still below 13, so it takes the values 1, 3, 5, 7, 9 and 11. Your program therefore prints six of those lines, and then this one:

The loop has finished

Example

Input:

6

Output:

Which times table would you like?
6 multiplied by 1 equals 6
6 multiplied by 3 equals 18
6 multiplied by 5 equals 30
6 multiplied by 7 equals 42
6 multiplied by 9 equals 54
6 multiplied by 11 equals 66
The loop has finished

Input:

10

Output:

Which times table would you like?
10 multiplied by 1 equals 10
10 multiplied by 3 equals 30
10 multiplied by 5 equals 50
10 multiplied by 7 equals 70
10 multiplied by 9 equals 90
10 multiplied by 11 equals 110
The loop has finished

The number can be 0 or negative as well, and your program does not need to treat those any differently. With 0 every product is 0, and with -3 the first line reads -3 multiplied by 1 equals -3.

Ask the question with its own print, and read the answer with a bare input() on the next line, rather than passing the question to input(...). The question is part of the output that is checked here, so its spelling, capital letters and punctuation count: it must read exactly Which times table would you like?.

Help! My code doesn't work!

Make sure that you check for the following things:

  • Iteration begins with while.
  • The while line has a condition.
  • The while line has a colon (:) at the end.
  • All the code you want to repeat is indented after the while, and all of it by the same amount. Never mix tabs and spaces in one file.
  • Any code that should run once the loop has finished is not indented.
  • The line that changes the counter is inside the loop, and it adds 2.
  • The input is wrapped in int(), or the number is multiplied as text.
  • Every number is wrapped in str() before it is joined onto text with a +.
  • Every space in the output comes from inside a string, so check the spaces around each variable.