FizzBuzz: Because I'm learning to program again

I've recently taken up learning to program the "Right Way" again, and so as a mark of progress I offer the below.An implementation of FizzBuzz as specified by Jeff Atwood in Python. This being a Python implementation where there is only one right way, there are probably identical solutions to this on the net already. Passing the FizzBuzz is as Atwood himself said nothing to be especially proud of. Yet for some God damned reason I am offering the below:

def main():
    for i in range (100):
        if i % 3 == 0 and i % 5 == 0:
            print "FizzBuzz"
            if i % 3 == 0:
                print "Fizz"
            if i % 5 == 0:
                print "Buzz"
                print i


For anyone who might want to follow the text I'm relearning programming in, I am reading John Zelle's Python Programing: an Introduction to Computer Science (first edition). The next language up will probably be Scheme. Eventually Perl will probably happen, but not for any noble reason.

4 thoughts on “FizzBuzz: Because I'm learning to program again

  1. Ha! this form messed a little with my previous reply – HTML reduces all whitespace(s) down to one space, but provides &-n-b-s-p-; (without the hyphens) if you absoulutely, definitely really, really, relly want to show a space character…

    Try print "FizzBuzz&-n-b-s-p-;" (without the hyphens)

    print "Fizz     "
    print "Buzz"

    If it was a line-break you wanted, try <BR>

Leave a Reply

Your email address will not be published. Required fields are marked *