1

I am trying to write a function to do the following:

  1. Write a function isRed() that accepts a string parameter and looks for the presence of the word ‘red’ in the string called text.

  2. If it is found, return boolean True otherwise False.

  3. Output the result of calling the function with the value in text.

This is what I have:

def isRed(text):
  if text.find(red):
    return (True)
  else:
      return (False)
  return red   

I get this error:

Program Failed for Input: ""
Expected Output: False
Your Program Output: 

I'm new to functions, and a bit confused as to why this isn't working.

t.hill
  • 11
  • 1
  • 4
  • 2
    The instructions say that the function is supposed to return `True` or `False`. Your function prints them, it doesn't return them. – Barmar Feb 08 '18 at 18:50

1 Answers1

2

you want

def is_red(text):

    if "red" in text:
        return True
    else:
        return False

print str(is_red(text))
Matt_G
  • 506
  • 4
  • 14