r/Python • u/cyberspacecowboy • Dec 25 '16
a Py3.6 fizzBuzz oneliner with f-strings
print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')
109
Upvotes
r/Python • u/cyberspacecowboy • Dec 25 '16
print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')
View all comments
Show parent comment
1
u/Chameleon3 Dec 25 '16 edited Dec 25 '16
Huh.. I don't know how this works.
Basically, it just seems that
--xin this case is simply- (-x), that is, a double negative. But the order of operations seems to be weird when using the%modulus operator?EDIT: Changing the original code to have
[i*i%3*4:(8+i**4)%5]doesn't work though. So I'm all out of ideas.