Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Custom Output Formatting | Formatting and Type Conversion
Working with Strings and Data Formats

bookChallenge: Custom Output Formatting

In many real-world scenarios, you need to present data in a way that's both readable and visually organized, such as generating reports, displaying high scores, or logging events. Mastering custom output formatting with strings is essential for producing professional, clear output that aligns information in columns, making it easy to scan and interpret. You will now apply your string formatting skills to a practical scenario: aligning names and scores in a columnar format. This exercise will reinforce your understanding of alignment options and help you create output that's both attractive and functional.

Taak

Swipe to start coding

Write a function that takes a list of tuples, where each tuple contains a name and a score. Return a single string in which each name is left-aligned and each score is right-aligned in columns. The width of the name and score columns should be determined by the longest name and the highest score, respectively. Each name and score should be separated by a single space. Each name-score pair should appear on its own line in the returned string.

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 4
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Custom Output Formatting

Veeg om het menu te tonen

In many real-world scenarios, you need to present data in a way that's both readable and visually organized, such as generating reports, displaying high scores, or logging events. Mastering custom output formatting with strings is essential for producing professional, clear output that aligns information in columns, making it easy to scan and interpret. You will now apply your string formatting skills to a practical scenario: aligning names and scores in a columnar format. This exercise will reinforce your understanding of alignment options and help you create output that's both attractive and functional.

Taak

Swipe to start coding

Write a function that takes a list of tuples, where each tuple contains a name and a score. Return a single string in which each name is left-aligned and each score is right-aligned in columns. The width of the name and score columns should be determined by the longest name and the highest score, respectively. Each name and score should be separated by a single space. Each name-score pair should appear on its own line in the returned string.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 4
single

single

some-alt