I'm trying to use the following query to reverse elements in a list using for loop and without built-in function but for some reason last 2 elements are not getting added. Any idea what I'm doing wrong here?
l = [5,7,9,1,8]
output = []
for i,v in enumerate(l):
output.append(l[len(l)-1])
l.remove(l[len(l)-1])
output
result: [8,1,9] expected: [8,1,9,7,5]