Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Comparison Solution

Why am I getting an error?

https://w.trhou.se/2r3kvbjk84

Why am I getting an error?? It's almost exactly like the teacher's, but I get an error around "line 18".

1 Answer

Asher Orr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Asher Orr
Python Development Techdegree Graduate 9,409 Points

Hi Julie! I got this error when I ran your program:

line 10, in <module>
    is_fizz = number % 3 == 0
TypeError: not all arguments converted during string formatting

Remember: a TypeError represents an error when an operation can't be performed (usually, but not always) because a value is not of the expected type.

Here's why you're getting this error:

Check out line 3 and 4 of your code:

number = input("Please enter a number: ")
# asks for input and stores their response (a string) in the variable "number."
numb = int(number)
# converts the variable "number" to an integer
# stores the integer in a variable called "numb"

Then look at lines 10 and 11:

is_fizz = number % 3 == 0
is_buzz = number % 5 == 0

The variable "number" holds a string. You can't divide a string by 3 or 5.

Try replacing that variable with numb in lines 10-11. I think that will fix your problem.

Let me know if you need more help!