这里面是哪个循环没有结束吗

这个代码好像是哪个循环没有结束吗 也运行不出来结果(是想求多项式导数的)
class process_derivative:
def init(self, function):
self.__function = function
def get_first_derivative(self):
lst1 = []
x = 0
y = len(self.__function)
while (x < y):
try:
temp = self.__function.find('-')
lst1.append(temp)
x = temp + 1
except ValueError:
break
if not len(lst1) == 0:
for i in lst1:
self.__function = self.__function[:i] + '+' + self.__function[i:]
lst2 = self.__function.split('+')
lst3 = lst2.copy
a = 0
for n in lst3:
try:
m = int(n)
lst2.remove(n)
except:
if len(n) == 1:
lst2 = lst2[:a] + '1' + lst2[a+1:]
a = a + 1
for j in lst2:
if '0' in j:
lst2.remove(j)
elif not '^' in j:
lst2 = str(lst2).replace(j[0],j)
else:
p = j.find('')
q = j.find('^')
if int(j[q+1:]) > 2:
new = str(int(j[:p]) * int(j[q+1:])) + j[p:q+1] + '^' + str(int(j[q+1:]) -1)
lst2 = str(lst2).replace(new, j)
else:
new = str(int(j[:p]) * int(j[q + 1:])) + j[p:q+1]
lst2 = str(lst2).replace(new, j)
new = ''
a = 0
for k in lst2:
a = a + 1
if a < len(lst2):
k = k + '+'
new = new + k
if new == '':
new = '0'
return 'The first derivative is:', new
test_four = process_derivative ('2
x^6-3x^8+5x+1')
result_four = test_four.get_first_derivative()
print(result_four)

代码格式太乱了,没有缩进是很难分析python代码的