Resolving "typeerror: not all arguments converted ... in Python"

In Python, “typeerror: not all arguments converted during string formatting” primarily occurs when:

  1. There is no format specifier.
  2. The format specifiers and the number of values are different.
  3. Two format specifiers are mixed.

Code

1. No format specifier with the string interpolation operator

# Since `x` is a string, the `%` operator is treated as a string
# interpolation operator. The error occurs because no format specifier
# is provided.
x = "11"
if(x % 2):
print("x is odd")
x = "11"
# This tells the compiler that % is used as the modulus operator
if(int(x) % 2):
print("x is odd")

2. Unequal format specifiers and values

fav_food = "pizza"
fav_show = "Friends"
fav_day = "Saturday"
fav_month = "June"
print("I like to eat %s while watching %s." % (fav_day, fav_food, fav_month, fav_show))
fav_food = "pizza"
fav_show = "Friends"
fav_day = "Saturday"
fav_month = "June"
print("I like to eat %s while watching %s." % (fav_food, fav_show))

3. Two format specifiers are mixed.

fav_food = "pizza"
fav_show = "Friends"
print ("I like to eat '{0}' while watching '{1}'." % fav_food, fav_show)
fav_food = "pizza"
fav_show = "Friends"
print ("I like to eat %s while watching %s." % (fav_food, fav_show))
fav_food = "pizza"
fav_show = "Friends"
print ("I like to eat {0} while watching {1}.".format(fav_food, fav_show))
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved