Skip to content

Instantly share code, notes, and snippets.

@kkt-ee
Created January 4, 2020 16:58
Show Gist options
  • Save kkt-ee/311f079c8d32b230a9197d5684ba87b1 to your computer and use it in GitHub Desktop.
Save kkt-ee/311f079c8d32b230a9197d5684ba87b1 to your computer and use it in GitHub Desktop.
"""
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits.
If the function is passed a valid PIN string, return true, else return false.
"""
def validate_pin(pin):
#return true or false
return pin.isdigit() and (len(pin) == 4 or len(pin) == 6)
#OR
def validate_pin(pin):
return len(pin) in (4, 6) and pin.isdigit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment