Note, my new tool kwik is available here
So doing a few fizzbuzz in different languages today and got to python,
Could someone tell me if the following is acceptable in interviews and what their most concise version is:
def fizzbuzz(i):
n = [i%3, i%5]
print(((n[0]==0)and(n[1]==0)and"fizzbuzz " + str(i))or((n[0]==0)and"fizz " +str(i))or((n[1]==0)and"buzz " + str(i))or str(i))
for i in range(0,102):
fizzbuzz(i)
Sam.
Top comments (2)
The Zen of Python says:
Sparse is better than dense.
While it is clever, I find the print line very hard to read. I would make it more readable and make my point.
Thank you,
this was exactly the kind of feedback I needed!