Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Created May 26, 2016 17:34
Show Gist options
  • Save dboyliao/331a196509e16a2bf4d6dbbe7285cdd6 to your computer and use it in GitHub Desktop.
Save dboyliao/331a196509e16a2bf4d6dbbe7285cdd6 to your computer and use it in GitHub Desktop.
Classic "Fizz Buzz" without "if-else"
from __future__ import print_function
def main():
while True:
x = int(input("Please enter an integer: "))
print([[[x, "Fizz"][x % 3 == 0], "Buzz"][x % 5 == 0], "FizzBuzz"][x % 15 == 0])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment