← Lesson
Chain of Thought
Joeven
Run
Reset
Python loads on first run
facts = [ "Alice is a doctor", "Doctors work at the clinic", "The clinic is closed on Sunday", "Today is Sunday", ] def direct_answer(question): if "alice" in question.lower() and "work" in question.lower(): return "yes" return "no" def with_steps(question): steps = [] closed = any("closed on Sunday" in f for f in facts) sunday = any("Today is Sunday" in f for f in facts) steps.append("Alice works at the clinic.") steps.append("closed Sunday: " + str(closed)) steps.append("today Sunday: " + str(sunday)) answer = "no" if closed and sunday else "yes" return steps, answer q = "Is Alice at work today?" print("direct:", direct_answer(q)) steps, ans = with_steps(q) for s in steps: print("step:", s) print("FINAL:", ans) print("direct was wrong", direct_answer(q) != ans)
Run to execute this in your browser. Nothing is sent to a server.