if num < 0: input('Only nonnegative intergervalues allowed, try again: ')elif num == 0: print('The factorial of 0 = 1')while num > 1: factor = factor * num num = num -1else: num = int(input('Only nonnegative intergervalues allowed, try again: '))
This is what I have. I'm only trying to use the while loop for the program. It prompts the user twice if the integer is negative and then the loop breaks. I need the loop to keep prompting the user until correct input is given. I'm not sure where the error is. Do I need a nested while loop or is the problem with the else statement?
I've tried another while loop underneath the original loop but unsure if I had it done correctly. Also tried moving some things around?