import hashlib component = 1 fount_it = False while fount_it == False: m = hashlib.md5() m.update(str('iwrupvqb').encode('utf-8') + str(component).encode('utf-8')) result = m.hexdigest() print("Component: " + str(component) + " Result: " + result) if(result.startswith('000000')): fount_it = True else: component += 1 print("Santa needs the number " + str(component))