fork download
  1. import re
  2.  
  3. string = """12345 67890 afghe
  4. abcde 23456 0abcd
  5. 34567 __fred01 45678
  6. 123.456 12345a 123.
  7. .456 ab00cd 00ab00"""
  8.  
  9. for m in string.split():
  10. if m.isdigit():
  11. print(m, 'Int')
  12. else:
  13. try:
  14. float(m)
  15. print(m, 'Float')
  16. except ValueError:
  17. print(m, 'STR')
Success #stdin #stdout 0.04s 64172KB
stdin
Standard input is empty
stdout
('12345', 'Int')
('67890', 'Int')
('afghe', 'STR')
('abcde', 'STR')
('23456', 'Int')
('0abcd', 'STR')
('34567', 'Int')
('__fred01', 'STR')
('45678', 'Int')
('123.456', 'Float')
('12345a', 'STR')
('123.', 'Float')
('.456', 'Float')
('ab00cd', 'STR')
('00ab00', 'STR')