Exercise 3: Fixing the
Hello
World
") -> two siblingelements, ['Hello', 'World'] -- identical to the chapter's own original result. WHY THIS WORKS AS AN ANSWER ------------------------------ The new elif branch is a direct structural copy of the existing p check, substituting 'li' for both the tag being opened and the tag being looked for on top of the stack -- which is exactly what the real HTML rule calls for: a new li closes a previous OPEN li, the same shape as a new (block-level tag) closing a previous open p, just with a single tag name playing both roles instead of a whole set playing one role. Because the two checks are independent elif branches -- neither one's own condition can ever be true when the other's is being evaluated for the same token, since top_tag can't simultaneously equal both 'p' and 'li' -- adding the li rule can't interfere with the p rule or vice versa. Each rule only ever fires when its own specific tag is what's currently open, which is why the original p-closing tests keep passing completely unchanged after the li rule is added alongside them.