code: def scanf(format, s=None, collapseWhitespace=True):
      
  
      if s is None:
          s = sys.stdin
  
      if hasattr(s, "readline"):
          s = s.readline()
  
      format_re, casts = scanf_compile(format, collapseWhitespace)
  
      found = format_re.search(s)
      if found:
          groups = found.groups()
          return tuple([casts[i](groups[i]) for i in range(len(groups))])
docs: scanf supports the following formats:
        %c        One character
        %5c       5 characters
        %d, %i    int value
        %7d, %7i  int value with length 7
        %f        float value
        %o        octal value
        %X, %x    hex value
        %s        string terminated by whitespace
  
      Examples:
      >>> scanf("%s - %d errors, %d warnings", "/usr/sbin/sendmail - 0 errors, 4 warnings")
      ('/usr/sbin/sendmail', 0, 4)
      >>> scanf("%o %x %d", "0123 0x123 123")
      (83, 291, 123)
  
  
      scanf.scanf returns a tuple of found values
      or None if the format does not match.