for n in range(1, 100) w = '' if not (n % 3) w = 'fizz' if not (n % 5) w += 'buzz' print(w or n)
I like this version because it demonstrates variable definition, operator precedence, and logical evaluation in Python as well as operation and assignment.
Get the best books from Hacker News each week
Join 4,500+ subscribers and get the best books mentioned on Hacker News every Thursday.
https://en.wikipedia.org/wiki/Fizz_buzz
https://www.amazon.com/Fizz-Buzz-Spoken-Numeracy-Games/dp/18...
I like this version because it demonstrates variable definition, operator precedence, and logical evaluation in Python as well as operation and assignment.