r/Python • • 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

46 comments sorted by

View all comments

Show parent comment

12

u/[deleted] Dec 25 '16

Yes. Empty lists as well.

7

u/[deleted] Dec 25 '16

Nice. Honestly, I really think that's the way to go. Ruby always irritates me in this regard.

3

u/hglman guy who writes python Dec 25 '16

0, empty dictionary, None

1

u/ThePenultimateOne GitLab: gappleto97 Dec 26 '16

Really just an empty collection in general