Created
June 5, 2018 20:49
-
-
Save MarkPuchalaII/5bafab4b15f811cdcd818f34fb76dbc2 to your computer and use it in GitHub Desktop.
FizzBuzz Python Solution
This file contains hidden or 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
# Print the numbers from 1 to 100. | |
# But for multiples of three print “Fizz” | |
# and for multiples of five print “Buzz” | |
# For multiples of both print “FizzBuzz” | |
for i in range(1,100) : | |
s = '' # Reset our string with every loop | |
if i%3 == 0 : s = 'Fizz' # Test if it's got a Fizz | |
if i%5 == 0 : s = 'Buzz' # Test if it's got a Buzz, too | |
if s == '' : s = i # If it's still in its original state (no fizz, no buzz) | |
print(s) # Then set it to the current number AND PRINT! | |
# I think there are two core takeaways from this exercise: | |
# (1) : Figure the most productive order to test for difference stances | |
# Is one question better to ask BEFORE another? | |
# (2) : When trying to test if nothing's been done, | |
# The question "Is it still in its original state?" is sometimes better | |
# than trying to throw the final test in an "else" clause. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment