Skip to content

Instantly share code, notes, and snippets.

@Demonstrandum
Last active June 3, 2017 13:49
Show Gist options
  • Save Demonstrandum/8ccc1eb31358fb8ae5a405a574635043 to your computer and use it in GitHub Desktop.
Save Demonstrandum/8ccc1eb31358fb8ae5a405a574635043 to your computer and use it in GitHub Desktop.
Lambda for FizzBuzz in Python
fizzbuzz = (
lambda n: 'fizzbuzz' if n % 15 == 0 else ('fizz' if n % 3 == 0 else ('buzz' if n % 5 == 0 else str(n) ))
)
# Interactivity
if __name__ == '__main__':
import sys
if len(sys.argv) == 1:
print('Give command line arguments of number to fizzbuzz.')
exit(1)
print(fizzbuzz(int(sys.argv[1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment