do you fail at FizzBuzz? simple prog test

John Machin sjmachin at lexicon.net
Mon May 12 19:26:44 EDT 2008


Terry Reedy wrote:
> "Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote in message 
> news:op.ua04evz4x6zn5v at a98gizw.cpe.telecentro.net.ar...
> En Sat, 10 May 2008 22:12:37 -0300, globalrev <skanemupp at yahoo.se> 
> escribió:
> 
> | (We used this question last year - some people gave a sensible answer
> | in less | than 5 minutes, but others did not even know how to start)
> 
> Another approach  I do not remember seeing here (under 10 minutes)
> 
> fb = ('FizzBuzz', None, None, 'Fizz', None, 'Buzz', 'Fizz',
>       None, None, 'Fizz', 'Buzz', None, 'Fizz', None, None)
> for i in range(1,101): print(fb[i%15] or i) #3.0

"#3.0" is rather cryptic. AFAIK that will work with *any* version of 
Python up to 3.0. The "() after "print" are required in 3.0 and optional 
in earlier versions.




More information about the Python-list mailing list