Skip to content

Commit 79d72d7

Browse files
authored
Enhance docstring for prompt function
Updated prompt function docstring with examples.
1 parent 61371f6 commit 79d72d7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

searches/binary_tree_traversal.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,17 @@ def post_order_iter(node: TreeNode) -> None:
259259

260260

261261
def prompt(s: str = "", width=50, char="*") -> str:
262-
"""Return a prompt string padded to the specified width."""
262+
"""Return a prompt string padded to the specified width.
263+
264+
>>> [prompt("Python", width=width) for width in range(8, 13)]
265+
[' Python ', ' Python *', '* Python *', '* Python **', '** Python **']
266+
267+
>>> prompt("Python", char=chr(0x1F40D))
268+
'🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 Python 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍'
269+
270+
>>> prompt("Python", -200)
271+
' Python '
272+
"""
263273
if not s:
264274
return "\n" + width * char
265275
left, extra = divmod(width - len(s) - 2, 2)

0 commit comments

Comments
 (0)