längste Substring, ohne Charaktere Python zu wiederholen

str = "AABBCDEFABC"		#string to check
i =0
j = 0
d={}					
sub_str_len = 0
while j < len(str):	#checks every character of the string
  if str[j] not in d or i>d[str[j]]:
    sub_str_len = max(sub_str_len,(j-i+1))
    d[str[j]] = j
  else:
    i = d[str[j]]+1
    sub_str_len = max(sub_str_len,(j-i+1))
    j-=1

  j+=1
    
print(sub_str_len)		#prints the size
    
Rui Coutinho