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
correct answer:
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.