Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is even and contains red - 3rd test #16

Open
johnylemony opened this issue Sep 26, 2017 · 2 comments
Open

Is even and contains red - 3rd test #16

johnylemony opened this issue Sep 26, 2017 · 2 comments

Comments

@johnylemony
Copy link

johnylemony commented Sep 26, 2017

I run into an issue, where I cannot go do 3rd test.

My code is

def is_even_and_contains_red(a_list):
if "red" in a_list:
    if len(a_list) % 2 == 0:
        return True
else:
    return False

and error message is

tests.py:30: in test_odd_with_red
assert is_even_and_contains_red(['red', 'blue', 'green']) == False
E AssertionError: assert None == False
E + where None = is_even_and_contains_red(['red', 'blue', 'green'])

I follow it step by step, but still cannot figure out what I'm missing.
I don't mind if someone just could give me a hint. I do not need ready answer :)

@IAMTARA
Copy link

IAMTARA commented Sep 27, 2017

You have two If statements, but only one Else statement. The Else corresponds to the first If.

But there's nothing in your code to say what happens if your second if statement is False, so if len(a_list) is an odd number it's just going to spit the results of the first If statement.

@ajtran303
Copy link

ajtran303 commented Sep 30, 2017

johnylemony Here is what I came up with!

def is_even_and_contains_red(a_list):
if 'red' in a_list and len(a_list) % 2 == 0:
return True
else:
return False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants