Editorial for Fizz Fuzz


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

This is basically the classic Bizz Buzz game.

Pretty straightforward, make sure you have your if statements in the right order!

n = input()
num1 = 1
num2 = 1
for i in range(n):
    if num1 % 7 == 0:
        print "Fizz",
    if num1 % 13 == 0:
        print "Fuzz",
    if num1 % 7 and num1 % 13:
        print num1,
    if num2 % 7 == 0:
        print "Fizz",
    if num2 % 13 == 0:
        print "Fuzz",
    if num2 % 7 and num2 % 13:
        print num2,
    print
    num1 += 1
    num2 += 2

Comments

There are no comments at the moment.