HELP = {
"1": ("Lend an item", "Type the item ID (like SS-01), then the member number. "
"Tell the member the due date shown."),
"2": ("Return an item", "Type the item ID. If a fee appears, collect it."),
"3": ("Show overdue items", "Lists items past their due date with member and days late."),
}
def show_help(choice):
"""Print help for one menu choice (used inside LendIt)."""
title, text = HELP.get(choice, ("Unknown option", "Choose a number from the menu."))
print(f"{choice}. {title}: {text}")
def help_page():
"""Return the same help as a Markdown page for the user guide."""
lines = ["# LendIt help", ""]
for key in sorted(HELP):
title, text = HELP[key]
lines += [f"## {key}. {title}", text, ""]
return "\n".join(lines)
show_help("2")
show_help("9")
print(help_page())
Output: the help for option 2, the friendly message for an unknown option 9, and then a Markdown help page with a heading and paragraph for each option, generated from the same dictionary. Change the text in one place and both the program and the page change.