hello i am struggling to comprehend this bit of the exercise, which i will mention below, how should i think of this problem, it’s literally confusing me
Lastly we need a way to pick the day with the most available people to attend so that we can schedule game night on that night.
Instructions
Write a function find_best_night
that takes a dictionary availability_table
and returns the key with the highest number.
off platform project abruptly goblin
gamers = []
# function that will update the 'gamers' list and add a new gamer if they have name and availability
def add_gamer(gamer, gamers_list):
if gamer.get("name") and gamer.get("availability"):
gamers_list.append(gamer)
else:
print("Missing crucial information")
# Create a dictionary called kimberly with the name and availability given above.
kimberly = {"name": "Kimberly Warner", "availability": ["Monday", "Tuesday", "Friday"]}
add_gamer(kimberly, gamers)
print(gamers)
# Continue creating more dictionaries for more gamers that want to join
add_gamer({'name': 'Thomas Nelson', 'availability': ["Tuesday", "Thursday", "Saturday"]}, gamers)
add_gamer({'name': 'Joyce Sellers', 'availability': ["Monday", "Wednesday", "Friday", "Saturday"]}, gamers)
add_gamer({'name': 'Michelle Reyes', 'availability': ["Wednesday", "Thursday", "Sunday"]}, gamers)
add_gamer({'name': 'Stephen Adams', 'availability': ["Thursday", "Saturday"]}, gamers)
add_gamer({'name': 'Joanne Lynn', 'availability': ["Monday", "Thursday"]}, gamers)
add_gamer({'name': 'Latasha Bryan', 'availability': ["Monday", "Sunday"]}, gamers)
add_gamer({'name': 'Crystal Brewer', 'availability': ["Thursday", "Friday", "Saturday"]}, gamers)
add_gamer({'name': 'James Barnes Jr.', 'availability': ["Tuesday", "Wednesday", "Thursday", "Sunday"]}, gamers)
add_gamer({'name': 'Michel Trujillo', 'availability': ["Monday", "Tuesday", "Wednesday"]}, gamers)
print(gamers)
# Setup weekly table
def build_daily_frequency_table():
return {"Monday": 0, "Tuesday": 0, "Wednesday": 0, "Thursday": 0, "Friday": 0, "Saturday": 0, "Sunday": 0}
count_availability = build_daily_frequency_table()
# Calculate how many days gamers are available
def calculate_availability(gamers_list, available_frequency):
for gamer in gamers_list:
for day in gamer["availability"]:
available_frequency[day] += 1
calculate_availability(gamers, count_availability)
print(count_availability)
#Write a function `find_best_night` that takes a dictionary `availability_table` and returns the key with the highest number.
def find_best_night(availability_table):
return availability_table.get() help here plz
this is where im stuck at I have written the function have put availability_table as an argument
Now the next step is i have to turn availability_table into a dictionary ?
then i have to find the highest key from its dictionairy?
I am confused because we have already the information on how many players we have weekly in count_availability
am i not supposed to use count_availability in my function? I peeked quickly on the solution fast enough so i dont remember the whole code, it doesn’t have count_availability in the function. i want to solve it by myself but just need some guidance. i’m not good with problem solving but i try daily to become better at it but i struggle with the process of thought