Skip to content
Advertisement

Line 7 Type error: Not all arguments converted during string formatting if (integerr % numberr) >= 1: [duplicate]

JavaScript

This is where I get my error

JavaScript

Advertisement

Answer

You have two mistakes.

  1. input always returns a string, as Simsteve7 mentioned. You can convert to an integer using int(), and convert to a string using str().

  2. You need to check if integerr % numberr == 0, because that means that numberr divides into integerr evenly; thus integerr is divisible by numberr.

Below is a solution for Python 2:

JavaScript

If you’re using Python 3, you can use f-strings. That would look like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement