Update solutions for dictionaries

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2024-05-08 16:47:22 +02:00
parent dd36861233
commit 1313fe8d42
1 changed files with 11 additions and 2 deletions

View File

@ -68,6 +68,15 @@ print("-" * 50)
# Aufgabe 5 & 6 mit Funktion
def print_salary_list(data, col_width=8):
"""Print a formatted list of employees and their salary.
Expects a a dictionary as the first argument:
{
"name": salary,
...
}
"""
heading = "Name".ljust(col_width) + " Gehalt"
print(heading)
print("-" * len(heading))
@ -76,7 +85,7 @@ def print_salary_list(data, col_width=8):
print_salary_list(salaries_new, 10)
print("-" * 50)
print_salary_list(salaries_all, 10)
print_salary_list(salaries_all, col_width=10)
print("-" * 50)