def natural(text):
 def num(s):
  'Convert text segment to int if necessary'
  return (int(s) if s.isdigit() else s)
 return [num(s) for s in re.split('(\\d+)', str(text))]

def natural ( text ) : def num ( s ) : return ( int ( s ) if s . isdigit ( ) else s ) return [ num ( s ) for s in re . split ( '(\\d+)' , str ( text ) ) ]
restrict input type to the natural numbers .