diff --git a/Basics/Exercise/25_decorators/25_decorators.py b/Basics/Exercise/25_decorators/25_decorators.py index ad5dbe58..0f924499 100644 --- a/Basics/Exercise/25_decorators/25_decorators.py +++ b/Basics/Exercise/25_decorators/25_decorators.py @@ -1,6 +1,6 @@ def check(f): def helper(x): - if type(x) == int and x > 0: + if type(x) == int and x >= 0: #this should be >= to include 0 as well. return f(x) else: raise Exception("Argument is not a non-negative integer") @@ -10,21 +10,21 @@ def helper(x): @check def factorial(n): - if n == 1: + if n == 1 or n==0: #0!=1 return 1 else: return n * factorial(n - 1) -for i in range(1, 10): +for i in range(10): print(i, factorial(i)) try: print(factorial(-1)) except Exception as e: - e.print_exception() + print(str(e)) try: print(factorial(1.354)) except Exception as e: - e.print_exception() \ No newline at end of file + print(str(e))