原代码是这样的:
for pop_dict in pop_date:
if pop_dict['Year'] == '2010':country_name = pop_dict['Country Name']
population = int(float(pop_dict['Value']))
code = get_country_code(country_name)
if code:
print(code + ":" + str(population) )
else:
print('ERROR - ' + country_name)
结果报错如题目所示。
原因是前一句末尾丢失了一个')'
参考链接:https://stackoverflow.com/questions/7035234/else-syntaxerror-invalid-syntax