Python 2
The variable nused in understanding the list is the same nthat is passed.
Understanding sets the meaning 1, 2and then finally 3.
Instead, change it to
arr = [0 for _ in range(n)]
or (amazing!)
arr = list(0 for n in range(n))
Python 3
This is fixed.
From the BDFL itself :
Python 3, . Python 2, "" :
x = 'before'
a = [x for x in 1, 2, 3]
print x
; Python " " . , , . . , ...
Python 3 " " , . , Python 3 ( print (x):-) 'before'.