Nov-23-2017, 04:52 AM
Code I am writing: Write code that iterates through number 1 - 20 and prints “Fizz” if it’s a multiple of 3, “Buzz” if it’s a multiple of 5, “FizzBuzz” if it’s a multiple of 3 and 5, and the number if it’s not a multiple of 3 or 5. It should only print one statement per number.
x=input ("Please Type a Number from 1 to 20.")
if x%3 == 0 and x%5 == 0:
print ("FizzBuzz")
elif x%3 == 0:
print ("Fizz")
elif x%5 == 0:
print ("Buzz")
else:
print ("Your Number is " + str(x))
My problem - when it executes it is skipping the first three statements and printing Your number is for all numbers.
x=input ("Please Type a Number from 1 to 20.")
if x%3 == 0 and x%5 == 0:
print ("FizzBuzz")
elif x%3 == 0:
print ("Fizz")
elif x%5 == 0:
print ("Buzz")
else:
print ("Your Number is " + str(x))
My problem - when it executes it is skipping the first three statements and printing Your number is for all numbers.