import operator, time class TinySuccessfulGoal: def __init__(self, start_value): self.value = start_value def meet_goal(self, value): print(f"i can totally make {self.value} be {value}!") while self.value != value: if self.value + 1 < value: print(f"Seems small. Maybe making it bigger?") self.do(operator.add, 1) elif self.value - 1 > value: print(f"Maybe too big. Could try making smaller?") self.do(operator.sub, 1) else: print(f"This seems really close. Maybe just a nudge!") self.do(operation.add, value - self.value) print(f"I'm at {self.value}!") print("I met the goal!") def do(self, operator, operand): self.value = operator(self.value, operand) if __name__ == '__main__': TinySucessfulGoal(3).meet_goal(7)