At the moment, I am attempting to accumulate values in dictionaries nested within a dictionary for homework purposes.
a = {
"Tennis Balls": {
"User Rating": 15,
"Available Colors": 5,
"Location": "Puppy Mart"
}
}
b = {
"Squeaky Toy": {
"User Rating": 48,
"Available Colors": 3,
"Location": "Pooch Shop"
}
}
c = {
"Stick": {
"User Rating": 32,
"Available Colors": 4,
"Location": "Pooch Shop"
}
}
d = {
"Old Shoe": {
"User Rating": 13,
"Available Colors": 2,
"Location": "Puppy Mart"
}
}
e = {
"Stuffed Animal": {
"User Rating": 14,
"Available Colors": 7,
"Location": "Dog Express"
}
}
puppy_toys = {"Toys": [a, b, c, d, e]}
total_user_ratings = 0
for toy in puppy_toys["Toys"]:
# insert your own code
individual_user_rating = puppy_toys["Toys"][toy]["User Rating"]
total_user_ratings += individual_user_rating
print(total_user_ratings)
I have to fill in # your line here with a single line of code that will allow the for loop to iterate through the dictionary puppy_toys and extract the total number of user ratings for toys located at "Pooch Shop", and then store the total in the variable total_user_ratings, but my line of code, shown below, doesn't seem to be working:
if["Location"] = "Pooch Shop":
Thanks for your assistance!