do you fail at FizzBuzz? simple prog test

Chuckk Hubbard badmuthahubbard at gmail.com
Fri Oct 3 13:47:20 EDT 2008


range(1,101), no?

On Tue, May 20, 2008 at 4:46 PM, Sells, Fred
<fred.sells at adventistcare.org> wrote:
> or
> for i in range(1,100):
>  print ('fizz','','')[i%3] + ('buzz','','','','')[i%5] or i
>
>> >
>> > "Write a program that prints the numbers from 1 to 100. But for
>> > multiples of three print "Fizz" instead of the number and for the
>> > multiples of five print "Buzz". For numbers which are multiples of
>> > both three and five print "FizzBuzz".
>> >
>> > for i in range(1,101):
>> >     if i%3 == 0 and i%5 != 0:
>> >         print "Fizz"
>> >     elif i%5 == 0 and i%3 != 0:
>> >         print "Buzz"
>> >     elif i%5 == 0 and i%3 == 0:
>> >         print "FizzBuzz"
>> >     else:
>> >         print i
>> >
>> >
>> > is there a better way than my solution? is mine ok?
>>
>>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.badmuthahubbard.com



More information about the Python-list mailing list