Format a Fixed-Width Table Row

Medium ⏱ 12 min 50% acceptance ★★★★★ 4.7
Write a function format_row(name, score) that returns a report-style line where name is left-justified in a 12-character field and score is right-justified in a 5-character field, e.g. "Alice 92" (as one string). This mimics building an aligned console report.

Examples

Example 1
Input
format_row("Alice", 92)
Output
'Alice          92'
Explanation

"Alice" padded to 12 chars left-justified, then 92 right-justified in 5 chars.

Example 2
Input
format_row("Bo", 7)
Output
'Bo               7'
Explanation

"Bo" padded to 12 chars, then 7 right-justified in 5 chars.

Constraints

  • name fits within 12 characters; score is a non-negative int fitting within 5 digits.

Topics

Input & Outputstring formatting

Companies

DeloitteAccenture

Hints

Hint 1

Use an f-string format spec: f"{name:<12}{score:>5}".

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.