# Even number list while using if statement with a % function

I’m stuck with this prompt and don’t know where to start since they threw remainder function in here:

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

Your function have to be named `print_even_numbers` and accept two parameters named `start` and `stop`.

Like Python’s range, you’ll have to start searching for even numbers by including `start` but excluding `stop`, remember:

``````for i in range(0, 10):
print(i)
``````

gives:

``````0
1
2
3
4
5
6
7
8
9
``````

so what I want `print_even_numbers(0, 10)` to give:

``````0
2
4
6
8
``````

## Hints

You can use the remainder of a value divided 2 to tell if it’s odd or even. And in Python to get this remainder use the `%` operator, see:

``````>>> 2 % 2
0
>>> 3 % 2
1
>>> 4 % 2
0
>>> 5 % 2
1
>>> 6 % 2
0
``````

The remainder is `1` if the value is odd and `0` if the value is even.

You’ll have to use an [if statement and a [print]

My input:
<def print_even_numbers(start, stop):
for num in (start,stop):
if num % 2 == 0:
print(print_even_numbers)>
Error I get:
Looks like your function is ignoring the given `start` and `stop` arguments.

For example, when I call `print_even_numbers(0, 10)` I get:

``````<function print_even_numbers at 0x7f2cf3129550>
<function print_even_numbers at 0x7f2cf3129550>
``````

And, when I call `print_even_numbers(10, 20)` I get:

``````<function print_even_numbers at 0x7f2cf3129550>
<function print_even_numbers at 0x7f2cf3129550>
``````

I was overthinking and forgot range
def print_even_numbers(start, stop):
for num in range(start,stop):
if num % 2 == 0:
print(num)

I was overthinking and forgot range
def print_even_numbers(start, stop):
for num in range(start,stop):
if num % 2 == 0:
print(num)

Please remember to surround code with “code fences”, a line of triple
backticks. This preserves formatting and indentation, which are very
important. Example:

`````` ```
paste your
code here
```
``````

I just wanted to point out the other issue in your previous attempt: it
was not calling the function. This statement:

`````` print(print_even_numbers)
``````

does not call (“run”) the function. It just prints a reference to the
function itself, hence the odd looking output.

Functions are objects and can be bound to names like any other Python
object. For example:

`````` >>> x = 1
>>>
>>> def y():
...     print("y function!")
...
>>> print(x)
1
>>> print(y)
<function y at 0x107982280>
>>>
>>> y()
y function!
``````

Only when you call the `y` function by saying `y()` does it actually
operate.

Cheers,
Cameron Simpson cs@cskk.id.au