[Tutor] For Loops Program Issue
John Weller
john at johnweller.co.uk
Tue Aug 18 12:32:56 EDT 2020
> -----Original Message-----
> From: Tutor <tutor-bounces+john=johnweller.co.uk at python.org> On Behalf Of
eric
> grunfeld
> Sent: 18 August 2020 16:17
> To: tutor at python.org
> Subject: [Tutor] For Loops Program Issue
>
> 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
Should be result = result * i
Range should be n+1
> 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
>
Forgot to Reply to All
John Weller
01380 723235
07976 393631
More information about the Tutor
mailing list