Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Comparison Solution

Julie Owens
Julie Owens
198 Points

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,086 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!