Skip to content

Instantly share code, notes, and snippets.

@cacapon
Last active November 15, 2019 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cacapon/f13044b1fc6f44f526c75b1ba5db41d1 to your computer and use it in GitHub Desktop.
Save cacapon/f13044b1fc6f44f526c75b1ba5db41d1 to your computer and use it in GitHub Desktop.
修正1
# 名前をしっかりつける
START_NUM = 1
END_NUM = 30
def play_fizzbuzz():
str_list = ['fizz', 'buzz', 'fizzbuzz']
# 指定の数値その1から指定の数値その2まで繰り返す
for count in range(START_NUM,END_NUM+1):
# countが15だったら
if count % 15 == 0:
print("{}:{}".format(count,str_list[2]))
# countが3だったら
elif count%3==0:
print("{}:{}".format(count, str_list[0]))
# countが5だったら
elif count %5 == 0:
print("{}:{}".format(count, str_list[1]))
else:
print("{}:".format(count))
play_fizzbuzz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment