Created
June 28, 2016 20:42
-
-
Save konstantinfarrell/c4f84ea579615da63de0eb325753b71d to your computer and use it in GitHub Desktop.
FizzBuzz one-liner in Python 3
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
# Using a lambda function | |
print(list(map(lambda i: "Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i), range(1,101)))) | |
# Using a for loop | |
for i in range(1, 101): print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar in length, but using a different technique, and I'm using
input
andcount
(itertools
), so it goes forever but is user controlled:I guess
count
shaves off a few more characters as well.