Tim
Tim

Reputation: 49

Python activity

I am attempting to use a program in Geany which is designed to tell me whether a number is even or odd. Here is the program I have written.

def activity01(num1):
    '''Determine if an input number is Even or Odd'''
    if [num1 % 2 == 0]
        return 'even'
    else: 
        return 'odd'

Can anyone tell me what is wrong with this program? It is telling me right now that line 3 has invalid syntax at the end. I am running the program in a test environment from the class I got the activity through.

Upvotes: 1

Views: 78

Answers (1)

moonpoint
moonpoint

Reputation: 126

Put a colon after if (num1 % 2 == 0). You should be able to use the code below for your function:

def activity01(num1):
   """Determine if an input number is Even or Odd"""
   if num1 % 2 == 0:
      return "even"
   else:
      return "odd"

print activity01(3)
print activity01(4)

Upvotes: 1

Related Questions