Andrew Parker Andrew Parker - 7 months ago 36
Python Question

Python treats "is" to pluralize string literal

Python version 3.4.3

Python converting string literal to plural. I cannot figure out how to solve this.

When I enter:

>>> x = ("The number % is incorrect" % 8)
>>> x
'The number 8s incorrect'

When I try to escape "is" I get an error.

>>> x = ("The number % \is incorrect" % 8)
ValueError: unsupported format character '\' (0x5c) at index 13


Try 'the number %d is incorrect' % 8

The problem is that python is reading your % (with the space, thanks, Ashwini) , and thinking that is your format character.