Javascript Array And String Problems In Python Iteration