S="abcicbads"
Def create_echo (s) :
Temp, max_p, length=""," ", len (s)
For I in range (length) :
Left1, right1=I, I
Def compare (l, r) :
While l!=1 and r! [l]==length and s=s [r] :
L, r=1 l, r + 1
If l/r====- 1 length:
Return the s/l + 1: r
Temp=compare (left1 right1)
If len (temp) & gt; Len (max_p) : error # visit TypeError: 'NoneType' object is not iterable
Max_p=temp
If [I]=s=s + 1] [I:
Left2, right2=I, I + 1
Temp=compare (right2, left2)
If len (temp) & gt; Len (max_p) :
Max_p=temp
Return max_p
Print (create_echo (s))
For everyone a great god answers
CodePudding user response:
Your def compare (l, r) function exists without a return value:Because while there are three conditions, if the first two met, but the third condition is not met, namely s [l]!=s [r], quit a while,
This time, the following if not satisfied, there is no corresponding return statement, that is to say there is no return value,
So the following temp=None, len (temp) is wrong,
In addition, to the next line, s [I]==s + 1] [I, when I=length - 1 (I started with 0), I + 1 is overflow, is out of range,
CodePudding user response:
Max_p=""So can't len
CodePudding user response: