Use str.rsplit()
to split a string into words, counting from the right. If you pass in None
it'll split on arbitrary-width whitespace, giving you neat stripped strings, and a count, letting you keep whitespace in the first column.
Short demo of what that means:
>>> 'Willem Jan van Steen 9859 77\n'.rsplit(None, 2)
['Willem Jan van Steen', '9859', '77']
Here the spaces in the name are preserved, but the two numbers at the end are now separate elements in a list. The newline at the end is gone.
If you loop over an open file object, you get separate lines, giving you a method to parse a file line by line:
with open(inputfilename) as inputfh:
for line in inputfh:
columns = line.rsplit(None, 2)
if len(columns) < 3:
continue # not a line with name and numbers
percentage = int(columns[2])
if 70 <= percentage <= 80:
# we have a line that falls within your criteria