Creating android clean list from dictionary

I receiving an error: KeyError: , this code was working earlier in the day and it runs fine for the apps_data, I have included the error code at the bottom in bold. Any suggestions are most welcome

[Profitable App Profiles for the App Store and Google Play Markets]
(https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets)

android_clean = [ ]
already_added = [ ]

for row in google_data[1:]:

name = row[0]
n_reviews = float(row[3])
if n_reviews == n_reviews[name] and name not in already_added:

android_clean.append(row)
already_added.append(name)

print(‘Length of android clean:’,len(android_clean))

KeyErrorTraceback (most recent call last)
in ()
** 8 name = row[0]**
** 9 n_reviews = float(row[3])**
—> 10 if n_reviews == reviews_max[name] and name not in already_added:
** 11 android_clean.append(row)**
** 12 already_added.append(name)**

KeyError: 'Photo Editor & Candy Camera & Grid & ScrapBook’

Please use triple back ticks ``` to format a code block. See the post below on how to format code block using triple back ticks.

Hello

I have formatted the code blocks as requested and included the error message. When I roll the code back to the previous checkpoint it appears to be correct, when I restart the kernel the code generates a key error, any practical guidance on this would be very useful

Usually you get a Key Error when you try and extract a value using a key that isn’t present in the dictionary.

In this case, it looks like the error is telling you that the way your code is written, you’re using the key Photo Editor & Candy Camera & Grid & ScrapBook in your dictionary at some point, even though it’s not existent in it.

On a sidenote, I think you also tried using triple back ticks wrongly!

Remember that back-ticks are that number to the left of the “1” key on most keyboards! Copy paste the following into a new post to check out how it’s supposed to look in the preview:

```
coded block
```

I have used the same code block for the ios dataset with no error(see below), as i stated in my earlier post the code block worked fine when i saved the checkpoint on Thursday evening.
I cannot see the source of key error in the first code block for android,i yett runs fine in the second code block for ios:

android_clean = [ ]
already_added = [ ]

for row in google_data[1:]:

```n_reviews = float(row[3])
```if reviews_max[name] == n_reviews and name not in already_added:
`````android_clean.append(row)
`````already_added.append(name)
        
print('Length of android clean:',len(android_clean))

KeyErrorTraceback (most recent call last)
<ipython-input-13-074c7500833b> in <module>()
      8     name = row[0]
      9     n_reviews = float(row[3])
---> 10     if reviews_max[name] == n_reviews and name not in already_added:
     11         android_clean.append(row)
     12         already_added.append(name)

KeyError: 'Photo Editor & Candy Camera & Grid & ScrapBook'

The code below works:

ios_clean = [ ]
already_added = [ ]

for row in apps_data[1:]:
```name = row[1]
```n_reviews = float(row[7])
```if n_reviews == reviews_max[name] and name not in already_added:
``````ios_clean.append(row)
``````already_added.append(name)
        
print('Length of ios clean:',len(ios_clean))
print('/n')
print(ios_clean[:5])

I suspect that you may have created the reviews_max dictionary using the apps_data dataset and are then using that same dictionary to try to filter the duplicates from google_data. 'Photo Editor & Candy Camera & Grid & ScrapBook' doesn’t exist in the iOS dataset. I was able to replicate your error when I did this, because that particular app doesn’t exist as a key. Try making a new dictionary using the google dataset and you should be able to get the filtered android data without the error.