Ad
  • Default User Avatar

    did you erase the first lines of the initial solution?

    import string
    

    I suppose that the import is needed by the sensei's code for the test. Put it there again, that should be good.

  • Custom User Avatar

    My bad! Should be len(pin) != 4 and len(pin) != 6. Thanks Unnamed.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    A couple errors:

    1.) The first 'if' statement is incorrect because Python doesn't support disconnected boolean statements. By this I mean that you have to change it to len(pin) != 4 and len(pin) != 6. Your code always returns False because the first part may be false, but or 6 will always be true since 6 is truthy.

    2.) The second 'if' statement is incorrect because i variable hasn't been declared. You have to loop through the string using a 'for' statement using i as a temporary loop variable. The 'if' statement can be contained in the 'for' loop.

  • Custom User Avatar

    Sure. Just post your code to this comment and use Markdown to format it, see here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting

  • Custom User Avatar

    You need to return the Boolean value instead of a string representation of the Boolean. The tests are only passing because they act on whether the return value is truthy or falsey. A non-empty string is truthy and therefore the function is truthy, thus meaning the test passes.

    return True instead of return 'true'

    return False instead of return 'false'

    Also, you need to use backticks (`) to format your code, not quotation marks.

  • Custom User Avatar

    Sure, just reply to this comment and post your code in Markdown using two sets of three backticks, see here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code

  • Custom User Avatar

    That specific type error occurs when you try to compare values with different data types (such as 5 < "5").

    It might because you're comparing a None type (description states It's your duty to verify that n is a valid positive integer number. If not, please, return false (None for Python)). None type doesn't have a value you can compare with and therefore gives an error.

    If you are still getting errors, just post your code and I'll help ya.