geostocker geostocker - 1 year ago 124
Python Question

Strange test-case result in CodeWars Kata

I need some help solving a CodeWars Kata that I'm kind of stuck with. For some reason I am receiving a False in one of the test-cases and I can't find the real reason behind it.

The instructions are to validate a

. The requirements are that the string needs to have the length of 4 or 6 and can only consist of digits.

This is my code:

def validate_pin(pin):

if (len(pin) != 4 or len(pin) != 6):
return False
return True
return False

It passes 9/10 tests. This is the input / output for the failed test:

I recieve False on validate_pin('1234'):

Wrong output for '1234': False should equal True

Answer Source
if (len(pin) != 4 and len(pin) != 6):
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download