jeudi 2 juillet 2020

multiples of 3 should be fizz 5 should be buzz both 3,5 should be fizzbuzz in a range (1,n)? [duplicate]

I tried to write a code using for loop and if statements but in the output along with the statements the numbers are also repeating.

n=int(input("enter number for n"))
for n in range(1,n):
        
        if n%3==0 and n%5==0:
            print("fizzbuzz",n)
        else:
            if n%5==0:
                print("buzz",n)
            if n%3==0:
                print("fizz",n)
        
        print(n)
       
        
 

Aucun commentaire:

Enregistrer un commentaire