Screen Link:
My Code:
android_clean = []
already_added = []
for app in android:
name = app[0]
n_reviews = float(app[3])
if (n_reviews == reviews_max[name]) and (name not in already_added):
android_clean.append(app)
already_added.append(name)
print(android_clean)
What I expected to happen:
From the above code I expected that the new list, ‘android_clean’ and already_added with contain the appened apps and names, but yet it still show empty list
What actually happened:
[]
I ran the above code in different editor and it works correctly but I don’t know why it is not working here on the Data quest plaform
It is difficult to tell from what you have provided here what the problem is. Can you please refer to these guidelines when creating your post: Guidelines for asking a technical question in our Community, specifically to include a link to the mission and a more descriptive title for your post.
Also, where is the variable reviews_max
being defined? I believe it is the logic surrounding this variable that is causing your problem but I’m not entirely sure. The code block below:
if (n_reviews == reviews_max[name]) and (name not in already_added):
android_clean.append(app)
already_added.append(name)
is saying that if n_reviews
is equal to reviews_max
then we should append the app
to the clean list. The fact that your clean list is empty is an indication that your if
clause is never evaluating to True
so we should take a deeper look at the conditions of the if
clause to see why that is.
I find it strange that it works in another editor tho…very strange indeed!