Javascript Loop Array And String Problems In Python