Where Am I Messing Up With Output Formatting?
So I got an error message when I tried to run my code and I can't figure out what exactly the problem is. It says it's a ValueError but I can't figure out which one exactly. Maybe
Solution 1:
You can't switch back and forth between automatic field numbering - what you get by specifying a simple {}
- and manual field specification, e.g. {0}
. If you want the same field repeated several times, as 'Word'
is in your example, you'll have to also specify what you want the other fields to be. For example, you might want to start with the first argument, 'Word'
, which is element 0
, and the fifth argument, '='*51
, as the last, which is element 4
:
>>>print("{0}{0:27}{0:39}{0:51}\n{4}".format("Word", "Occurence", "Avg. Score", "Std. Dev.", "="*51))
WordWord Word Word
===================================================
You'll have to decide for yourself which arguments you want to be placed where in the format string.
Post a Comment for "Where Am I Messing Up With Output Formatting?"