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

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,452 Points

My code doesn't work even though it's same as the solution provided

name = input("Please enter your name: ")

number = input("Please enter a number: ")

print('Hi {}!\nThe number {}...'.format(name, number))

is_fizz = number%3 == 0

is_buzz = number%5 == 0

if is_fizz and is_buzz:

print('is a FizzBuzz number.')

elif is_fizz:

print('is a fizz number.')

elif is_buzz:

print('is a buzz number')

else: print('is neither a fizzy or a buzzy number.')

I get this error:

Traceback (most recent call last): File "C:/Users/smemo/OneDrive/Desktop/fizzbuzz.py", line 27, in <module> is_fizz = number%3 == 0 TypeError: not all arguments converted during string formatting

1 Answer

Steven Parker
Steven Parker
231,269 Points

The error is from attempting to perform a remainder operation on a string. Convert the input into a number to fix:

number = int(input("Please enter a number: "))  # "int" converts string to number