Question about Step 6 in this Abruptly Goblins off-platform project … Why couldn’t we have used ‘gamers’ (from the first line of code that we wrote and which holds a list of all the qualifying gamer dictionaries) as the first argument in the calculate_availability function? I mean, the question even literally says, “Write a function called calculate_availability
that takes a list of gamers as an argument…” ?
Here is the link to the project …
https://www.codecademy.com/courses/learn-python-3/informationals/python3-abruptly-goblins
Here is the code …
gamers = []
def add_gamer(gamer, gamers_list):
if gamer.get("name") and gamer.get("availability"):
gamers_list.append(gamer)
else:
print("Missing information")
kimberly = {
"name": "Kimberly Warner",
"availability": ["Monday", "Tuesday", "Friday"]
}
add_gamer(kimberly, gamers)
print(gamers)
*A bunch of gamer dictionaries*
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()
def calculate_availability(gamers_list, available_frequency):
for gamer in gamers_list:
for day in gamer['availability']:
available_frequency[day] += 1