Python Loop Over String Javascript Substring