Challenged myself to see if it was possible to do FizzBuzz in one line. The answer: yep!
1 2 |
# FizzBuzz in one line (minus this comment)
print ‘n‘.join([‘%d%s%s‘ % (i, ‘Fizz’*(i%3==0), ‘Buzz’*(i%5==0)) for i in xrange(101)]) |
Challenged myself to see if it was possible to do FizzBuzz in one line. The answer: yep!
1 2 |
# FizzBuzz in one line (minus this comment)
print ‘n‘.join([‘%d%s%s‘ % (i, ‘Fizz’*(i%3==0), ‘Buzz’*(i%5==0)) for i in xrange(101)]) |