def ask(t): print(t) sys.stdout.flush() return input() import sys from itertools import product s = "0123456789" for lst in product(s,repeat=3): res = ask("".join(lst)) if res == "unlocked": exit()