For Introduction to Python, Guided Project: Profitable App Profiles for the App Store and Google Play Markets - Step 5/14 the code is not working to create a dictionary because float can not convert a value.
Below is the code:
reviews_max = {}
for app in g_apps_data[1:]:
name = app[0]
n_reviews = float(app[3])
if name in reviews_max and reviews_max[name] < n_reviews:
reviews_max[name] = n_reviews
elif name not in reviews_max:
reviews_max[name] = n_reviews
print(reviews_max)
OUTPUT:
ValueErrorTraceback (most recent call last)
in ()
3 for app in g_apps_data[1:]:
4 name = app[0]
----> 5 n_reviews = float(app[3])
6
7 if name in reviews_max and reviews_max[name] < n_reviews:
ValueError: could not convert string to float: ‘3.0M’