Count - executes code differently when validating


In what way does your code behave incorrectly? Include ALL error messages.

Code executes perfectly in editor, however it does not provide the same result when executed in the validation. I get the error:

"Oops, try again. Your function fails on count([4, 'foo', 'foo'],5). It returns 1 when it should return 0."

While when I write print count([4, 'foo', 'foo'],5) after my function it returns the correct value.

What do you expect to happen instead?

I expect the code to run in the validation with no mistakes in output.

def count(sequence,item):
    while item in sequence:
        del sequence[sequence.index(item)]
    return c


you modify the list, this seems to give problems with the validation


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.