A Loopless FizzBuzz
1 2 3 4 5
n=map(str, range(101)) n[::3]=['Fizz']*34 n[::5]=['Buzz']*21 n[::15]=['FizzBuzz']*7 print '\n'.join(n[1:])
References : - -1- - -2- - -3- - -4-
Alernative :
n=map(str, range(101)) n[::3]=['Fizz']*34 n[::5]=map(lambda a:'FizzBuzz' if a=='Fizz' else 'Buzz', n[::5]) print '\n'.join(n[1:])
Alternative :
n=map(str, range(101)) n[::5]=['']*21 n[::3]=['Fizz']*34 n[::5]=map(lambda a:a+'Buzz', n[::5]) print '\n'.join(n[1:])
That is shorter than the version I came up with.
Alernative :
Alternative :
That is shorter than the version I came up with.