It is supposed to look like the image in the attached file Donkey and It is easily possible to make it organized with the names Griffindor and Hufflepuff because they have the same number of characters so it just takes trial and error for proper spacing. The problem is I can't get it to look organized if the team names are of a different length, which is what I am curious about.
As for the assignment, I've already been told its good enough and have turned it in since its due at the end of the period, but I really wanted to know if there was a more efficient way that could work with varying string lengths.
- Code: Select all
print("\nHouse\t\tGoals\t\tSnitch\t\tGoals per Minute")
print(team1, "\t", format(score1, "4d"), "\t\t 1\t\t", format(gpm1, "15.2f"))
print(team2, "\t", format(score2, "4d"), "\t\t 0\t\t", format(gpm2, "15.2f"))
print("\nTotal goals for the game:", end=" ")
print("Average time between goals:", end=" ")
If you want to see all of the source code it is in the quidditch_statistcs.txt file and isn't very long. The part referencing about is the last bit after the last comment. I'm also using Python ver 3.3.2 in case anyone needed to know that.