It's working but need tabs


So my code is working but for functionality and realistic purposes I would like to add in tabs into where it's printed so that I can easily match up the students name with their test, quiz, and homework scores. ie; put it in rows or even just tab it out.
Any solutions?
(Not looking for work arounds just want to know what I can do to do this.)

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0],

alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0],

tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0],


students = [lloyd, alice, tyler]

print lloyd["name"], alice["name"], tyler["name"] #Names
print lloyd["homework"], alice["homework"], tyler["homework"]
print lloyd["quizzes"], alice["quizzes"], tyler["quizzes"]
print lloyd["tests"], alice["tests"], tyler["tests"]

For Reference

I also know I can do it like this but, I don't want that.

print lloyd["name"], lloyd["homework"], lloyd["quizzes"], lloyd["tests"] #Names
print alice["name"], alice["homework"], alice["quizzes"], alice["tests"]
print tyler["name"], tyler["homework"], tyler["quizzes"], tyler["tests"]

UPDATE: Thank you Stetim!


You can concatenate tabstops in between your 'columns' with code like this:
print lloyd["name"] + '\t' + alice["name"] + '\t' + tyler["name"]

Because of the list lengths, it will most likely take many tabstops '\t\t\t\t' and require a wide console view because wrapping will ruin the table you're trying to build.


you can use .format() which allows for padding and much more:


How would I implement this to be used with a list though?


but here:

print lloyd["name"], alice["name"], tyler["name"] #Names

its a string, so you can use it perfectly? I don't see a problem:

print "{} {}".format(lloyd["name"],alice["name"])

now you just need to add the padding to the {}


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.