I am trying to make the function print "Even" or "Odd" but cannot.

x = raw_input()

def is_even(x):

```
if x % 2 == 0:
print "Even!"
return True
else:
print "Odd!"
return False
```

I am trying to make the function print "Even" or "Odd" but cannot.

x = raw_input()

def is_even(x):

```
if x % 2 == 0:
print "Even!"
return True
else:
print "Odd!"
return False
```

It still won't print.

The code "passes" and executes without error as I had it but it still won't print "even" or "odd".

I think I need to call the function somehow?

x = raw_input("Number to test: ")

def is_even(x):

```
if x % 2 == 0:
print "Even!"
return True
else:
print "Odd"
return False
```

Thanks.

But doesn't that defeat the purpose of asking for raw_input?

I want to have the user enter a number and print even or odd. Not just return true or false.

I got it this far... but it always prints "even"

x = raw_input("Number to test: ")

def is_even(x):

```
if x % 2 == 0:
return True
else:
return False
```

if is_even:

print "Even"

else:

print "Odd"

won't work because is_even() is a function that expects and argument.

```
if is_even(x):
print "Even"
else:
print "Odd"
```

should work.

try this for the raw input processing

```
def is_even(x):
if x % 2 == 0:
return "Even!"
#return True
else:
return "Odd"
#return False
x = raw_input("Number to test: ")
#the user could enter a non-digit
print is_even(int(x)) if x.isdigit() else None
```

```
def is_even(x):
if x % 2 == 0:
return True,"Even!"
else:
return False, "Odd"
x = raw_input("Number to test: ")
#the user could enter a non-digit
print is_even(int(x)) if x.isdigit() else None
```

```
def is_even(x):
return not x%2
x = raw_input("Number to test: ")
#the user could enter a non-digit
print is_even(int(x)) if x.isdigit() else None
```

guys i think u are taking this too far, the question says:

Define a function is_even that will take a number x as input.

If x is even, then return True.

Otherwise, return False.

this is just the simple code i used that worked:

def is_even(x):

if x % 2 == 0:

return True

else:

return False

what you just wrote is the same code pesented here

which is is just as simple as what you suggesting, The raw_input part is his way of testing the correctness of the method

I answered here has well..

```
numbers = [1,2,3,4,5,6,7,8,9];
def is_even(number):
if number % 2 == 0:
print number, "is even"
return True
else:
print number, "is odd"
return False
for number in numbers:
is_even(number)
```

Continuing the discussion from 15 is_even:

Hey, I think I understand what you are getting at. I believe you are missing the call to function (hopefully term is right).. Going off your OP:

```
x = int(raw_input())
def is_even(x):
if x % 2 == 0:
print "Even!"
return True
else:
print "Odd!"
return False
print is_even(x)
```

`raw_input()`

converts input to a string and adding `int()`

for an integer. Hopefully that helps to the question you were asking.