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 do else with for loops in Python, but you'll need to balance your parentheses on:
log_f.write("Name:%s \n Email: %s" % (name, email)
which should actually be
log_f.write("Name:%s \n Email: %s" % (name, email))
(Note the extra final parenthesis.)