[Tutor] For Loops Program Issue
eric grunfeld
grunfelderic at gmail.com
Tue Aug 18 11:17:00 EDT 2020
Good Morning Everyone:
I am currently taking a beginners Python course that is being taught by
Google, on the Coursera platform.
I have been working on a problem but I seem to be obtaining an error
message after running the program.
Here is the problem:
def factorial(n):
result = 1
for i in range(result,n):
result = result * n+1
return result
print(factorial(4)) # should return 24
print(factorial(5)) # should return 120:
Here is the the error message that I have been receiving:
Here is your output:
85
781
Not quite. Pay attention at the operations that the code is
doing and make sure that the factorial function returns the
product of the numbers between 1 and n.
Based upon my understanding, it appears that my issue is with the set-up of
my range.
I look forward to any thoughts or comments that you may have.
All the best,
Eric
More information about the Tutor
mailing list