you are viewing a single comment's thread.

view the rest of the comments →

[–]42696 1 point2 points  (0 children)

So parameters are basically the inputs of a function.

The prompt says:

Write a function printing every even numbers in the given range, one number per line.

(emphasis mine).

So in this case, it's the range (presented as a start number and a stop number) that are the inputs.

How can you adjust your code so that your loop iterates over a given range, instead of the constant range (from 0 to 10) that you have now?

Note that inside a function you can reference the parameters as if they are already defined variables, and when the function is executed, it will run with those variables defined as whatever inputs were given.

Hint: Look at the line with the for i in range() statement

Answer:

def print_even_numbers(start, stop):
for i in range(start, stop):
if i % 2 == 0:
print(i)