python invalid syntax after for loop