I am a beginner who started Python a few days ago. I'm writing a code to study and to get a Factorial. I want to write a code to terminate the program when a negative number is entered (without the break statement), but the code below has not progressed for several hours. I hope you can help me! This code works, but the condition I want to satisfy is not to use break, but to exit the program if a negative number is entered
Code >>
def factorial(n):
if n == 1:
return 1
return n * factorial(n - 1)
while True:
num = int(input("Enter a number: "))
if num < 0:
continue
print(str(num) + "! =", factorial(num))