def log_times(log, find, times):
count = 0
for line in log.split('\n'):
if find in line:
count += 1
if count >= times:
return True
return False
if __name__ == '__main__':
print(log_times(open('/var/log/auth.log').read(), 'password check failed for user (maxwork)', 2))