Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding:utf-8
- # 3の倍数の時と3が付く数字の時、!を付けて表示
- three_flag = False
- for n in range(1, 500 + 1):
- n_str = str(n)
- for i in range(len(n_str)):
- if n_str[i] == "3":
- print(str(n) + "!")
- three_flag = True
- break
- if three_flag == False:
- if n % 3 == 0:
- print(str(n) + "!")
- else:
- print(str(n))
- three_flag = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement