I want to split lines into fields and print them neatly aligned. I do not know in advance how long the names are, so I can't use a fixed format like the ones given in other Stack Overflow questions.
This is the kind of output I would like to get:
Simpson, Bartholomew Homer 12345 CSEE £25000
Jackson, Michael 15675 History £34000
Clown, Krusty the 56746 Economics £67000
This is the code I have written so far:
def printFormat(details):
details = details.split()
lastname = details[-1]
firstnames = " ".join(details[3:-1])
name = ", ".join([lastname, firstnames])
ID_Subject = " ".join(details[0:2])
money = details[2]
print "%s,%s %s %s" % (lastname,firstnames,ID_Subject,money)