4 ms·
I like how this solution uses several nice Python features; I found a way to simplify it further while still using the same overall approach: screams = {3: '
by schoen 8y ago
I like how this solution uses several nice Python features; I found a way to simplify it further while still using the same overall approach:
screams = {3: 'fizz',5:'buzz',21:'yaow'}
for i in range(100):
out = [screams[j] for j in screams if i%j == 0]
print("".join(out) if out else i)
Edit: here's an even shorter version:
screams = {3: 'fizz',5:'buzz',21:'yaow'}
for i in range(100):
out = "".join(screams[j] for j in screams if i%j == 0)
print(out or i)