if len(user_hash) > 0:
with open(log_file, \"w\") as log_f:
for name in user_hash:
log_f.write(\"Name:%s \\n Email: %s\" % (name, email)
else l
You can't supply a condition with an else statement. else means "everything else" --- that is, everything else but whatever conditions you specified in an earlier if. It's not clear what you're trying to accomplish with that else, but perhaps you mean it to be an if.
It could also be an elif ("else if"), but if you mean it to be an else for the earlier if clause, then you need to unindent it so it's at the same indentation level as the if. An if and it's else/elif have to line up at the same indentation level.
(There is such a thing as an else clause for a for statement, but it doesn't look like that's what you want here.)