I do not know much about python, but I am surprised the following code works:
import sys
prev = [sys.maxint]*(5)
j = 0
print prev[j]
print prev[j-1]
In general I thought second print statement should give me an error. Why does this work?
I need to convert some python code into C++, and in C++ this will not work.
mylist[-1]returns the last item ofmylist,mylist[-2]the second-to-last item etc.This is by design. Read the tutorial.