def print_path(size, position): print("home", end=" ") for i in range(size): if i == position: print("*", end=" ") else: print(".", end=" ") print("pub") def drunkman_simulator(size, steps): if size < 3: print("Path too short") return position = int((size - 1) / 2) print_path(size, position) for _ in range(steps): direction = randint(1,2) if direction == 1: position += 1 else: position -= 1 print_path(size, position) if position == size - 1: print("Ended in the pub again!") return elif position == 0: print("Got home!") return