Setting fixed width display of a list
I'm trying to display a list which has several lines in it, each with several items, as a neat "table" where each "column" has a fixed width. For example: John Watson assistant 50 Single Sherlock Holmes detective 40 Single I've looked around for solutions and they're all too complicated for my level... I've only just started Python but this is an assignment I've got and we weren't given much guidelines at all so I'm left trying to figure everything out by myself. I've tried something like: print(surname,+',', name, '%10s' % job, '%10s' % age, '%10s' % status) Where all the names in the brackets were previously saved as variables with values input by the user upon request. That worked, it looked neat. But then I realized once I have more than just one row it will be misaligned. So the same method won't work for a whole "table". I've tried something like this then: (Previously typed a function to open a text file and read and import the lines into a newly created list) for i in employees: x = 32-(len(i[0]+i[6])) print(i[6] + ',', i[5], i[4], i[3], ' '*x + i[0], i[2], i[1]) but I got an error saying the index list is out of range. So I've run out of ideas. Basically I've got a small text file with a few lines with words separated by spaces. Each word represents a specific thing, such as job, age, status, surname etc. The first names vary - some people have 1 name, others have 4. So some lines have 7 items while others just 4. My task is to display the rows in the format: Surname, first names|job|age|status. There must not be several different values for first name. They must be displayed under the same "column" and connected with the surname by a comma. Now I can't even figure out how to display a whole set of different values with a fixed width, let alone how to get around merging several words into just one fixed width "column". Any help would be greatly appreciated. And remember I am FAR FROM advanced. I have ju