0
def getresults(candidates, parties, votes, percentageofvote):
    results = "/=\/=\=/=\=/=\=/=\=/=\Election Results/=\=/=\=/=\=/=\=/=\=/=\=/=\/\n\n Candidate Party   Votes   Percent\n\n\n"
    for x in range(len(candidates)):
        results = results + "%12.12s"%candidates[x] + "\t%3.3s"%parties[x] + "\t%3.3s"% votes[x] + "\t" + str(percentageofvote[x]) + "\n"
    return(results)

So my question is what the %12.12, and other percents are doing in this code. I understand everything else about the code, what its doing etc but I don't quite understand what the percent does. I know that normally it works as a modulus and will tell you the remainder between two numbers being divided. Clarification on this would be much appreciated.

1 Answers1

0

It does formatting of strings.

More info on it: http://docs.python.org/2/library/string.html#format-examples