Andrew Parker Andrew Parker - 1 year ago 104
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download