[Tutor] self keyword in recursive function
Marc Tompkins
marc.tompkins at gmail.com
Sat May 31 07:55:53 CEST 2014
On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav <ritwikraghav14 at gmail.com>
wrote:
> It has again given some error I do not understand. This time my code is:
>
> count = 0
> def getPersistence(self,n):
>
> product = 1
> if len(str(n)) == 1:
> return self.count
> else:
> a = str(n)
> for i in a:
> product *= int(i)
> self.count += 1
> return self.getPersistence(product)
>
> and the error is:
>
> Correct Return Value: No
>
> Answer check result:
> Result must be not null.
>
> Execution Time: 0.017s
>
> Peak memory used: 24.551MB
>
> abnormal termination (exit 1)
>
> Standard Output:
>
>
> Standard Error:
> Traceback (most recent call last):
> File "Wrapper.py", line 182, in <module>
> AttributeError: 'module' object has no attribute 'PersistentNumber'
>
>
> I do not understand what it is trying to tell me? I tried to test it for
> 99.
>
>
The error is in some part of your code that you _haven't_ posted here -
please post your entire script (as an attachment, if that's more
convenient) and we'll be better able to help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140530/be9aa514/attachment.html>
More information about the Tutor
mailing list