python报错 TypeError: 'int' object has no attribute '__getitem__'

class Solution(object):

def lengthOfLongestSubstring(self, s):

x=str(s)

if x=="":

return 0

maxlength = 1

a = [i for i in range(1,len(x)+1)]

for i in range(len(a)):

a[i]=["" for i in range(0,len(x))]

for i in range(len(x)):

abx = 1

a[i][0]+=x[i]

for j in range(1,len(a[i])+1):

if x[i]==x[i-j] or i-j<0:

break

else:

if type(a[i-1][j-1]) != int:

a[i][j]=a[i-1][j-1]+a[i][0]

abx = abx+1

if maxlength < abx:

maxlength = abx

else: break

return maxlength

python报错  TypeError: 'int' object has no attribute '__getitem__'
在pyCharm上运行没有问题,但在这里就报错了。
希望大神可以帮帮我!!

以上是 python报错 TypeError: &#x27;int&#x27; object has no attribute &#x27;__getitem__&#x27; 的全部内容, 来源链接: utcz.com/p/937909.html

回到顶部