请帮我修复此代码。这是一个反转整数数组的函数,例如:[1,2,3,4,5] -> [5,4,3,2,1]。错误是:
builtins.TypeError: unsupported operand type(s) for /: 'list' and 'int'
请给我一个解决方案。谢谢
def reverse(array):
'''
[1,2,3,4,5] -> [5,4,3,2,1]
This method returns a reversed integer array.
'''
size = len(array)
halfsize = array/2
size -= 1
r = array[size]
temp = None
for s in range(0, halfsize):
temp = arrayOne[s]
array[s] = r
array[size] = temp
size -= 1
r=arrayOne[size]
return arrayOne
a = reverse ([1, 4, 3, 4, 5])