Reputation: 359
What I am missing here?
print('i % 100 = %d ' % (i % 100))
gives me: ValueError: unsupported format character ' ' (0x20) at index 7
a = i % 100
print('i % 100 = %d ' % (a))
Same error again.
Upvotes: 2
Views: 133
Reputation: 129537
You have to escape %
in the format string (using another %
):
print('i %% 100 = %d ' % (i % 100))
In general, the character after an unescaped %
is treated as a format specifier, and a space is an invalid specifier, hence the error.
Upvotes: 2