Created
September 14, 2014 09:09
-
-
Save youkidearitai/cee0d7ab571fd1e8fc86 to your computer and use it in GitHub Desktop.
初めてのpython
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
| #!/usr/env/bin python | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| def fizzbuzz(i): | |
| if i % 3 == 0 and i % 5 == 0: | |
| return 'fizzbuzz' | |
| elif i % 3 == 0: | |
| return 'fizz' | |
| elif i % 5 == 0: | |
| return 'buzz' | |
| else: | |
| return str(i) | |
| argv = int(sys.argv[1]) + 1 if len(sys.argv) > 1 else 30 + 1 | |
| separator = sys.argv[2] if len(sys.argv) > 2 else "\n" | |
| print separator.join(map(fizzbuzz, range(1, argv))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment