L2 = [1,2,3]
print(L2.reverse)
输出结果为
<built-in method reverse of list object at 0x000002032889FD48>
想要的结果为
[3, 2, 1]
错误原因:reverse不可以直接print
正确代码为
L2 = [1,2,3]
L2.reverse()
print(L2)
L2 = [1,2,3]
print(L2.reverse)
输出结果为
<built-in method reverse of list object at 0x000002032889FD48>
想要的结果为
[3, 2, 1]
错误原因:reverse不可以直接print
正确代码为
L2 = [1,2,3]
L2.reverse()
print(L2)