I had a job interview today. During it I was asked to write down an algorithm that will reverse a list. First I offered the answer using the reversed() method:
How about something like that:
x = [1, 2, 3, 4, 5] for i in xrange(len(x) / 2): x[i], x[-i - 1] = x[-i - 1], x[i] print(x)
The idea is to swap array elements from opposite directions