ValueError: “unsupported format character ‘a’ (0x61) at index 9” in Python


Do you ever got this error message when running code like:

1
print("Hello world this should be a long paragraph and you need %s, %s and some of % needed by %s" % (var1, var2, var3, var4))

Well, when this problem show-up, it’s not about Unicode and you should convert all variable value into ASCII.
This error will show if you forgot to put “s” after “%”.

1
2
print("Hello world %" % var1)
ValueError: "unsupported format character ‘a’ (0x61) at index 9" in Python

Solution:

1
print("Hello world %s" % var1)

Seems you’re tired and need a break for a while 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.