code: def newpin(digits=4):
      
      randnum = randint(0, 10 ** digits)
      while len(str(randnum)) > digits:
          randnum = randint(0, 10 ** digits)
      return (u'%%0%dd' % digits) % randnum
docs: Return a random numeric string with the specified number of digits,
      default 4.
  
      >>> len(newpin())
      4
      >>> len(newpin(5))
      5
      >>> newpin().isdigit()
      True