from random import randint def print_row(size, position): print("home", end=" ") for i in range(size): if i == position: print("*", end=" ") else: print(".", end=" ") print("pub") def drunkman_simulator(size, num_steps): if size < 3: print("Path too short") return position = int((size - 1) / 2) print_row(size, position) for _ in range(num_steps): direction = randint(0, 1) if direction == 0: position += 1 else: position -= 1 print_row(size, position) if position == size - 1: print("Drunk ended in the pub again!") return elif position == 0: print("Drunk guy got home safely.") return print("Drunk guy fell asleep on the street.") drunkman_simulator(10, 10)