fork download
  1. import re
  2. text = ['bits', 'scrap 1.2', 'bits and pieces', 'junk 3.4.2']
  3. print([re.sub(r'\s+\d+(?:\.\d+)*$', '', x) for x in text])
  4. # => output = ['bits', 'scrap', 'bits and pieces', 'junk']
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
['bits', 'scrap', 'bits and pieces', 'junk']