def factorial(n): if n<0: raise ValueError('n should be positive') elif not isinstance(n,int): raise TypeError('n should be integer') if n == 1: return 1 else: return n*factorial(n-1) def main(): print 'This program finds n!' choice = 'y' while choice == 'y' or choice == 'yes': n=input('please, input n:') print n, type(n) F=factorial(n) print "%d! = %d"%(n,F) choice = raw_input('Would you like to continue? (Y or Yes):') choice=choice.lower() print 'Have a good day!' main()