Python FizzBuzz

github logo ・1 min read

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):


twitter logo DISCUSS (2)
markdown guide

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!

Classic DEV Post from Jun 9

Top 5 Soft Skills for Software Engineer

Soft skills are as critical as technical skills for a software engineer. No one works in isolation. Each person has to deal with teammates, colleagues, managers, etc. Therefore team interpersonal skills are essential too. Soft skills include things like good communication, honesty, teamwork, integrity, organization, empathy, etc.

UKJP profile image

Sore eyes? now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️