Problem 175745 · easy · Phase 01 Prerequisites & Setup

Is It a Valid PIN?

strings · isdigit · len · booleans

A cash machine accepts a PIN only if it is made of digits only and is exactly 4 or 6 characters long. Given the string pin, return True if it is acceptable and False otherwise. Spaces, signs and decimal points are not digits.

Examples

Input:  pin = "1234"
Output: True

Input:  pin = "12345"
Output: False

Input:  pin = "12a4"
Output: False

Constraints

  • 0 <= len(pin) <= 20
  • pin may contain any printable characters

Goals

  • Check the length of a string
  • Check that every character is a digit
  • Return a boolean
Starting Python…