<分区>
您好,有人可以帮助我处理这段代码吗?我在第 28 行(A.extend(n))收到错误消息:“‘int’对象不可迭代”,因为我是 python 的新手,所以我无法找出一个解决方案感谢任何帮助
编辑:我之前尝试过 append 并且之前遇到内存错误,想知道 extend() 是否是添加元素的正确方法,但似乎我犯了一个错误并以无限循环告终 感谢您的建议,它真的帮助了我
print("Ax^2+Bx+C")
a = int(input("a"))
b = int(input("b"))
c = int(input("c"))
i, j, k, l = 0, 0, 0, 0
A = []
C = []
B = []
ano = []
bno = []
no = 0
noc = 0
n = 2
a2 = a
c2 = c
if (a != 1) or (b != 1):
while i != 1:
while a2 % n == 0 and c2 % n == 0:
if a2 % n == 0:
a2 /= n
# A.extend(n)
no += 1
if c2 % n == 0:
c2 /= n
# A.extend(n)
no += 1
A.extend(n)
ano.extend(no)
no = 0
n += 1
if a2 == 1:
A.extend(1)
A.extend(1)
i = 1