Created
November 15, 2019 01:16
-
-
Save cacapon/6a588a1209d8f791b3d49fcde5680d28 to your computer and use it in GitHub Desktop.
修正3
This file contains 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
# 行間,コメント間隔を揃える | |
START_NUM = 1 # fizzbuzz開始位置 | |
END_NUM = 30 # fizzbuzz終了位置 | |
def play_fizzbuzz(): | |
# START_NUMからEND_NUMまでのfizzbuzzを出力します。 | |
str_list = ['fizz', 'buzz', 'fizzbuzz'] # 3単語までしか対応していません。 | |
for count in range(START_NUM, END_NUM + 1): # ENDに+1しているのはrangeが終了の数-1で止まってしまうため。 | |
# TODO:15とか3とか5を変数で管理したい | |
if count % 15 == 0: | |
print("{}:{}".format(count, str_list[2])) | |
elif count % 3 == 0: | |
print("{}:{}".format(count, str_list[0])) | |
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