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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Amy Mou](https://uploads.teamtreehouse.com/production/profile-photos/10758504/micro_IMG_2271.jpg)
Amy Mou
8,920 PointsAnother Approach, Is it good?
This is my approach, it works. Wondering if it's fine? name = input("Please enter your name: ") number = int(input("Please enter a number: "))
TODO: Make sure the number is an integer
TODO: Print out the User's name and the number entered,
making sure the two statements are on separate lines of output.
print("Hello {}! ".format(name)) print("The number {}...".format(number))
TODO: Compare the number the user gave with the different
FizzBuzz conditions.
*********************
If the number is divisible by 3, print "is a Fizz number."
If the number is divisible by 5, print "is a Buzz number."
If the number is divisible by both 3 and 5, print "is a FizzBuzz number."
Otherwise, print "is neither a fizzy or a buzzy number."
*********************
if number/15 == int(number/15): print("is a FizzBuzz number.") elif number/3 == int(number/3): print("is a Fizz number.") elif number/5 == int(number/5): print("is a Buzz number") else: print("is neither a fizzy or a buzz number.")
TODO: Define variables for is_fizz and is_buzz that stores
a Boolean value of the condition. Remember that the modulo operator, %,
can be used to check if there is a remainder.
Using the variables, check the condition of the value, and print the necessary
string
4 Answers
![Liam Trant](https://uploads.teamtreehouse.com/production/profile-photos/1611312/micro_CROPPED-passport_lpt.jpg)
Liam Trant
2,918 PointsHi Amy!
Objectively, yes it is good since the game functions as expected. However, the TODOs in the exercise are suggested so that we can practice using techniques we've learned which will eventually help enable us to write more efficient code.
I too first had a working solution, but I realized that my code wasn't actually assigning boolean values to the is_fizz and is_buzz variables. Also, while my "if, elif" logic was returning boolean values correctly, the body of my logic was using all ints. I also misunderstood how the modulo % was supposed to be used. All of this didn't dawn on me until I watched the solution video!
![Son-Hai Nguyen](https://secure.gravatar.com/avatar/9e9ebd5e6d534a414c04f9cb460df947?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Son-Hai Nguyen
2,481 PointsHi Amy,
It's an interesting concept you got there! I myself came up with a solution of dividing the number for 15 instead of using the "and" function boolean. I think it works fine so far.
Cheers.
![Lynn Collins](https://secure.gravatar.com/avatar/15900fa4b9d479ef9e0942edeab1406d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Lynn Collins
10,080 PointsMy code failed!!!!
![Piotr Sochaczewski](https://secure.gravatar.com/avatar/f515a061e17198836fac42b173ae2960?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Piotr Sochaczewski
13,038 PointsI try this challenge in another way. I used method .is_integer() to valid if is true or false.
if (number/3).is_integer():
if (number/5).is_integer():
print("{} is a FizzBuzz number.".format(number))
else:
print("{} is a Fizz number.".format(number))
elif (number/5).is_integer():
print("{} is a Buzz number.".format(number))
else:
print("{} is neither a fizzy or a buzzy number.".format(number))