Python Loop Over String Javascript Substring Function In C