... ]
File "<stdin>", line 3
]
^
SyntaxError: invalid syntax
>>> arg1
10
>>> if (arg1 % 5 == 0) and (arg1 % 3 == 0):
... print('FizzBuzz')
...
>>> arg1 = 15
>>> if (arg1 % 5 == 0) and (arg1 % 3 == 0):
... print('FizzBuzz')
...
FizzBuzz
# コード例
arg1 = 1
if arg1 % 3 == 0:
print('Fizz')
if arg1 % 5 == 0:
print('Buzz')
if (arg1 % 3 == 0) and (arg1 % 5 == 0):
print('FizzBuzz')
print('それ以外')
#実行例
oct:tnal% python3 week4.py [~]
それ以外
def judge_number(arg1):
arg1 = 1
if arg1 % 3 == 0:
print('Fizz')
if arg1 % 5 == 0:
print('Buzz')
if (arg1 % 3 == 0) and (arg1 % 5 == 0):
print('FizzBuzz')
print(str(arg1))
judge_number(1)
judge_number(2)
def judge_number(arg1):
print('今の数字は',arg1,'だよ: ', end='')
if (arg1 % 3 == 0) and (arg1 % 5 == 0):
return 'FizzBuzz'
if arg1 % 3 == 0:
return 'Fizz'
if arg1 % 5 == 0:
return 'Buzz'
return(str(arg1))
result = judge_number(1)
print('1の結果は', result, 'だよ')
result = judge_number(2)
print('2の結果は', result, 'だよ')
result = judge_number(3)
print('3の結果は', result, 'だよ')
result = judge_number(4)
print('4の結果は', result, 'だよ')
result = judge_number(5)
print('5の結果は', result, 'だよ')
result = judge_number(6)
print('6の結果は', result, 'だよ')
result = judge_number(7)
print('7の結果は', result, 'だよ')
result = judge_number(8)
print('8の結果は', result, 'だよ')
result = judge_number(9)
print('9の結果は', result, 'だよ')
result = judge_number(10)
print('10の結果は', result, 'だよ')
result = judge_number(11)
print('11の結果は', result, 'だよ')
result = judge_number(12)
print('12の結果は', result, 'だよ')
result = judge_number(13)
print('13の結果は', result, 'だよ')
result = judge_number(14)
print('14の結果は', result, 'だよ')
result = judge_number(15)
print('15の結果は', result, 'だよ')