Skip to content

Commit 5c49864

Browse files
committed
create OS counter to find out if more OS other than end user's preffered OS avaiable and display an offer message
1 parent 275feb8 commit 5c49864

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

prep-exercises/exercise_eleven.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,20 @@ def laptops_counter(preferred_operating_system_input:str) ->int:
9898
return f"There are {sum} laptops with {user_os} operating system"
9999

100100
print(laptops_counter(preferred_operating_system_input))
101+
102+
103+
104+
105+
def more_available_os(user_os: operatingSystem) ->int:
106+
os_counter = {}
107+
for laptop in laptops:
108+
os_counter[laptop.operating_system] = os_counter.get(laptop.operating_system, 0) + 1
109+
110+
max_count = max(os_counts.values())
111+
112+
user_os_count = os_counts.get(user_os, 0)
113+
114+
if user_os_count < max_count:
115+
print(f"If you’re open to using {user_os} operating system, you’ll have a better chance of getting a laptop.”")
116+
117+

0 commit comments

Comments
 (0)