Skip to content

Commit 981f35c

Browse files
committed
use preferred_operating_system.index()
1 parent 9990844 commit 981f35c

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎Sprint5-exercise/laptop-allocation.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ class Laptop:
2727

2828

2929
def sadness(person: Person, operating_system: OperatingSystem) -> int:
30-
sad: int = 100
31-
for index, os in enumerate(person.preferred_operating_system):
32-
if os == operating_system:
33-
sad = index
34-
return sad
35-
36-
return sad
37-
30+
try:
31+
return person.preferred_operating_system.index(operating_system)
32+
except ValueError:
33+
return 100
3834

3935
def allocate_laptops(
4036
people: list[Person], laptops: list[Laptop]

0 commit comments

Comments
 (0)