Python Madlibs.py code and error message
Stephen Hansen
me at ixokai.io
Thu Apr 28 02:50:46 EDT 2016
On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote:
> Stephen Hansen <me+python at ixokai.io> writes:
>
> > The error message means there's a mismatch between the number of
> > formatting instructions (ie, %s) and arguments passed to formatting. I
> > leave it to you to count and find what's missing or extra, because I'm
> > seriously not going to do that :)
>
> Better: when you have many semantically-different values, use named (not
> positional) parameters in the format string.
>
> Some simple format string examples:
>
> "First, thou shalt count to {0}" # References first positional
> argument
> "Bring me a {}" # Implicitly references the first
> positional argument
> "From {} to {}" # Same as "From {0} to {1}"
> "My quest is {name}" # References keyword argument 'name'
> […]
>
> <URL:https://docs.python.org/3/library/string.html#formatstrings>
Except the poster is not using Python 3, so all of this is for naught.
--
Stephen Hansen
m e @ i x o k a i . i o
More information about the Python-list
mailing list