From a3382fea02d209178cb150ccae25022d84c7a4bf Mon Sep 17 00:00:00 2001 From: Jarvis Jeason Jacob Date: Thu, 27 Aug 2026 08:36:32 +0530 Subject: [PATCH 1/3] Add docstring to prompt() --- searches/binary_tree_traversal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/searches/binary_tree_traversal.py b/searches/binary_tree_traversal.py index 47af57f7f94d..2e70bcfe251b 100644 --- a/searches/binary_tree_traversal.py +++ b/searches/binary_tree_traversal.py @@ -259,6 +259,7 @@ def post_order_iter(node: TreeNode) -> None: def prompt(s: str = "", width=50, char="*") -> str: + """Return a prompt string padded to the specified width.""" if not s: return "\n" + width * char left, extra = divmod(width - len(s) - 2, 2) From 79d72d76ed258824d1019d130a2b05b139fccc1d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 8 Sep 2026 18:10:07 +0200 Subject: [PATCH 2/3] Enhance docstring for prompt function Updated prompt function docstring with examples. --- searches/binary_tree_traversal.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/searches/binary_tree_traversal.py b/searches/binary_tree_traversal.py index 2e70bcfe251b..82123a169f6b 100644 --- a/searches/binary_tree_traversal.py +++ b/searches/binary_tree_traversal.py @@ -259,7 +259,17 @@ def post_order_iter(node: TreeNode) -> None: def prompt(s: str = "", width=50, char="*") -> str: - """Return a prompt string padded to the specified width.""" + """Return a prompt string padded to the specified width. + + >>> [prompt("Python", width=width) for width in range(8, 13)] + [' Python ', ' Python *', '* Python *', '* Python **', '** Python **'] + + >>> prompt("Python", char=chr(0x1F40D)) + '🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 Python 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍' + + >>> prompt("Python", -200) + ' Python ' + """ if not s: return "\n" + width * char left, extra = divmod(width - len(s) - 2, 2) From f9a5478514dbe07bd7bbbaabbacdb78f283288a7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 8 Sep 2026 18:13:14 +0200 Subject: [PATCH 3/3] Enhance prompt function with width parameter Updated prompt function to accept width parameter and modified example outputs accordingly. --- searches/binary_tree_traversal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/searches/binary_tree_traversal.py b/searches/binary_tree_traversal.py index 82123a169f6b..5e5a276f5a7a 100644 --- a/searches/binary_tree_traversal.py +++ b/searches/binary_tree_traversal.py @@ -264,8 +264,11 @@ def prompt(s: str = "", width=50, char="*") -> str: >>> [prompt("Python", width=width) for width in range(8, 13)] [' Python ', ' Python *', '* Python *', '* Python **', '** Python **'] - >>> prompt("Python", char=chr(0x1F40D)) - '🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 Python 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍' + >>> prompt("Python", width=40, char=chr(0x1F40D)) + '🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 Python 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍' + + >>> len(prompt("Python")) + 50 >>> prompt("Python", -200) ' Python '