256 Kilobytes

Answers in Scripting and Automation | By August R. Garcia


168 views, 0 RAMs, and 0 comments

Tags: Python, Error Messages, String Formatting

Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite Owner

This is technically a different error message, but is what was causing the issue.

string = "The value is one hundred (100)."

# Raises an error 
print("This is 100% of a sentence:\n%s" % string)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: %o format: an integer is required, not str

# This does not raise an error
print("This is 100%% of a sentence:\n%s" % string)
# This is 100% of a sentence:
# The value is one hundred (100).

TL;DR: Escape the percent symbol (%) with two percent symbols when using string formatting in Python. 

Download more RAM. 🐏 ⨉ 0Posted by August R. Garcia 7 months ago 🕓 Posted at 26 October, 2019 01:56 AM PDT

Sir, I can do you a nice SEO.

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account

Answers— Read More

Find more related content below!