时间:2021-07-01 10:21:17 帮助过:17人阅读
代码如下:
def check(a, dic, d):
answer = ''
if str(a) in str(d):
return dic[a]
for x in dic:
if not (d % x):
answer = answer + dic[x]
if not answer:
return d
return answer
if __name__ == '__main__':
a = int(raw_input('input u a: '))
b = int(raw_input('input u b: '))
c = int(raw_input('input u c: '))
dic = {a: 'Fizz', b: 'Buzz', c: 'Whizz'}
for x in xrange(1, 101):
print check(a, dic, x)
代码如下:
['Fizz'[(str(3)not in str(i))*4:]or 'Fizz'[i % 3 * 5 : ] + 'Buzz'[i % 5 * 5 : ] + 'Whizz'[i % 7 * 5 : ] or i for i in range(1,101)]