[Tutor] A style question
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 18 Apr 2002 17:30:17 +0100
> Is there a way to reduce the number of lines needed
> output.write("Number of lines: %s\n" % str(linecount))
> output.write("Total word count: %s\n" % str(wordcount))
> output.write("Total character count: %s\n\n"% str(charcount))
> for word in keyList:
strOut = "word: %15s,\toccurences: %d\n" % (word,occurences[word])
output.write(strOut)
Notes:
%15s -> a string occupying 15 spaces(makes it all line up)
\t -> tab
%d prints a number, no need for str()
Any better?
Alan G.