Fixed python syntax issue with for loops