How can I write a Python function that given an array A of numbers returns an array B that has the elements of A in reverse order? WITHOUT using the reverse function in python, and instead use a for loop?
This is what I have so far and then I call the function main() in the shell and it gives me some errors and one of them is 'B' is not defined.
def ReverseArray(A):
n = len(A)
for i in range(0, n-1):
B[n-i-1] = A[i]
return (B)
def main():
A = [13, 21, 15, 38, 49] # Test case for ReverseArray function
B = ReverseArray(A)
print(B)
Where did I go wrong?