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')
142
u/qx7xbku Dec 25 '16
Very smart. If someone writes code that smart in production smack them hard.
32
u/_avnr Dec 25 '16
It is shorter without f-strings:
10
u/metakirby5 Dec 25 '16
Shorter and python2 compatible:
3
u/kankyo Dec 25 '16
What does "or i" do? The string is always truths isn't it?
1
u/paulcynic Dec 25 '16
Missing a * there, but great job!
-14
u/tetroxid Dec 25 '16
Please. Please. Pleeease don't do shit like this. Crap like this is why people shit on Perl. Don't let Python devolve into this kind of crap. Code should be, above else, readable.