Skip to content

Commit fa7880c

Browse files
committed
Fix dictionary key type to use person.name
1 parent 95e0e1d commit fa7880c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

laptop_allocation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Laptop:
4949
# NOTE: laptops list is modified on purpose.
5050
# After allocation, it shows the laptops that are still left.
5151

52-
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
52+
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[str, Laptop]:
5353
sorted_people_OS_count=sorted(people,key=lambda p:len(p.preferred_operating_system))
5454
sadness=0 # local variable sadness counter
5555
allocated_history : Dict[Person,Laptop] ={}
@@ -74,7 +74,7 @@ def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person
7474

7575
return allocated_history , sadness
7676

77-
def print_final_allocation(allocated_history :dict[Person,Laptop], sadness:int ) :
77+
def print_final_allocation(allocated_history :dict[str,Laptop], sadness:int ) :
7878
for name , laptop in allocated_history.items() :
7979
print(f"{name:<10} : Laptop Id {laptop.id:<3} - OS({laptop.operating_system.name}) ")
8080
print(f"Total sadness is : {sadness}")

0 commit comments

Comments
 (0)