TypeError: argument of type 'NoneType' is not iterable - Can't find out why not!

Mission screen Link: https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/5/removing-duplicate-entries-part-two

Hi there! I’m an absolute beginner in Python, and bit stuck on my first DataQuest guided project… I want to check if the string name is in the list already_added but I get back TypeError: argument of type 'NoneType' is not iterable

Here is the very last block of my code, hope it’s in there:

reviews_max = {}

for row in dataset2[1:]:
    name = row[0]
            
    n_reviews = float(row[3])
    
    if name in reviews_max and reviews_max[name] < n_reviews:
                        
        reviews_max[name] = n_reviews
                               
        d1 = {name: n_reviews}

        reviews_max.update(d1)
        
    if name not in reviews_max:
       
        reviews_max[name] = n_reviews

android_clean = []
already_added = []

for row in dataset2[1:]:
    name = row[0]
    n_reviews = float(row[3])
    
    thismany = reviews_max[name]
    
    if thismany == n_reviews and name not in already_added:
            amdroid_clean = android_clean.append(this_row)
            already_added = already_added.append(name)
        
print(len(android_clean))

I get back:

TypeErrorTraceback (most recent call last)
<ipython-input-55-dbe670cdfa56> in <module>()
      8     thismany = reviews_max[name]
      9 
---> 10     if thismany == n_reviews and name not in already_added:
     11             amdroid_clean = android_clean.append(this_row)
     12             already_added = already_added.append(name)

TypeError: argument of type 'NoneType' is not iterable

Hope someone can find the problem with this info. Thanks for trying!

1 Like

The error is most likely because of the following -

amdroid_clean = android_clean.append(this_row)
already_added = already_added.append(name)

You don’t assign the result of an append back to the list variable. You just append it directly like so -

android_clean.append(this_row)
already_added.append(name)

That should resolve the error.

Also, please make sure that next time you separate out the code and the error message for improved readability.

3 Likes

Great! Thanks a lot doctor, it worked!
And as for the seperation of code and error message:
apparently the three back ticks to enter back into markdown didn’t work. I’ll have to brush up on my very limited markdown syntax knowledge some more to find out what went wrong there…

2 Likes

@frisodehartog: just sharing a cheatsheet that I use here.

Happy Learning!

2 Likes

I fixed it for you. You need to have the ``` in a separate line.

2 Likes