Skip to content

Instantly share code, notes, and snippets.

@youkidearitai
Created September 14, 2014 09:09
Show Gist options
  • Select an option

  • Save youkidearitai/cee0d7ab571fd1e8fc86 to your computer and use it in GitHub Desktop.

Select an option

Save youkidearitai/cee0d7ab571fd1e8fc86 to your computer and use it in GitHub Desktop.
初めてのpython
#!/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