Created
August 10, 2015 20:40
-
-
Save lynnlangit/62140fb94b0752334fea to your computer and use it in GitHub Desktop.
FizzBuzz Python Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz(intList): | |
if intList % 3 == 0 and intList % 5 == 0: | |
print "Fizzbuzz" | |
elif intList % 3 == 0: | |
print "Fizz" | |
elif intList % 5 == 0: | |
print "Buzz" | |
else: | |
print intList | |
print "\n".join(fizzbuzz(intList) for intList in (range(1, 101))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're printing to STDOUT, not returning a value, so this code will fail like this:
The use of the variable name 'intList' is a bit misleading as you're passing in a single value, not a list.
You're performing the same two arithmetic operations twice (each) so that's doing more work than is necessary.
If you would like some pointers then I would be more than willing to help :)
-Jamie Ivanov
(If you google me then you should find me otherwise my google email is my first name, period, my last name.)