[Tutor] self keyword in recursive function

Ritwik Raghav ritwikraghav14 at gmail.com
Sat May 31 08:06:39 CEST 2014


That's all the code I'm writing. The complete problem statement is:
http://pastebin.com/E970qYXk


On Sat, May 31, 2014 at 11:25 AM, Marc Tompkins <marc.tompkins at gmail.com>
wrote:

> 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.
>



-- 
Ritwik Raghav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140531/4e33388e/attachment.html>


More information about the Tutor mailing list