这个代码有问题吗
a =b = a.copy()
c = b.reverse()
d = c.index(5)
print(len(a) - d)
Traceback (most recent call last):
File "C:/Users/ASUS/Desktop/1.py", line 4, in <module>
d = c.index(5)
AttributeError: 'NoneType' object has no attribute 'index' b.reverse()是对b进行反转,是原地操作,不会有返回值(返回值是None),应该改成c = list(reversed(b)) tommyyu 发表于 2023-1-19 22:44
b.reverse()是对b进行反转,是原地操作,不会有返回值(返回值是None),应该改成c = list(reversed(b))
如此,thank you
页:
[1]