I'm new to coding and this is my first post here so I hope I am doing it correctly.
I am learning Python and trying to do the "FizzBuzz" program. I am trying to implement a string asking the user if they want to continue, with a "y" or "n" response, if "y" it keeps running, if "n" it simply says 'Thank you for playing".
I just cannot seem to get the latter response to work. Any help would be greatly appreciated. Here is my code (from PyCharm):
valid_input = True
def number_game():
num = int(input("Please type a whole number "))
if (num % 3 == 0) and (num % 5 == 0):
print("Fizz Buzz")
elif num % 3 == 0:
print("Fizz")
elif num % 5 == 0:
print("Buzz")
else:
print(num)
cont = input("Continue? Y or N").lower()
if cont == "y":
number_game()
else:
print("Thank you for playing")
# Should I use a while loop somewhere in code instead?
# while valid_input:
# number_game()
# print("\n")