Bug or intended behavior?

justin walters walters.justin01 at gmail.com
Fri Jun 2 13:34:10 EDT 2017


On Fri, Jun 2, 2017 at 10:17 AM, <sean.dizazzo at gmail.com> wrote:

> Can someone please explain this to me?  Thanks in advance!
>
> ~Sean
>
>
> Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print "foo %s" % 1-2
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for -: 'str' and 'int'
> >>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Try this:

    print "foo %d" % (1-2)



More information about the Python-list mailing list