350-x Guided Project: Profitable App Profiles for the App Store and Google Play Markets

please i am really having a problem with the first guided project.

reviews_max = {}
for app in Andriod:
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

when i run this code, it gives me this answer below

ValueErrorTraceback (most recent call last)
in ()
2 for app in Andriod:
3 name = app[0]
----> 4 n_reviews = float(app[3])
5 if name in reviews_max and reviews_max[name] < n_reviews:
6 reviews_max[name] = n_reviews

ValueError: could not convert string to float: ‘3.0M’

whats wrong?

from the solution book, they used the same lines of code with mine and the error didn’t occur

I’m so happy that i discovered and solved the bug.

Steps i took

had to find the length of my Andriod

print(Andriod[10472])
[‘Life Made WI-Fi Touchscreen Photo Frame’, ‘1.9’, ‘19’, ‘3.0M’, ‘1,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘’, ‘February 11, 2018’, ‘1.0.19’, ‘4.0 and up’]

i now compared it with the length of the previous andriod

print(Andriod[10471])
[‘Xposed Wi-Fi-Pwd’, ‘PERSONALIZATION’, ‘3.5’, ‘1042’, ‘404k’, ‘100,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Personalization’, ‘August 5, 2014’, ‘3.0.0’, ‘4.0.3 and up’]

actually the float(app[3]) from the Andriod[10472] was showing ‘3.0M’ which was has a string value attached to it.

but Andriod[10471] showed ‘1042’ which are integers. had to delete Andriod[10472]

and when i performed

reviews_max = {}
for app in Andriod:
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

it worked out with the corresponding value

print(‘Expected length:’, len(Andriod) - 1181)
print(‘Expected length:’, len(reviews_max))
showing this.
Expected length: 9659
Expected length: 9659

2 Likes

ok guys please i need help this time around. i’m having a problem with this project. keep on receiving this error message as feedback.
TypeErrorTraceback (most recent call last)
in ()
4 for app in andriod_clean:
5 name = [0]
----> 6 if is_english(name):
7 andriod_english.append(app)
8 for app in ios:

in is_english(string)
3
4 for i in string:
----> 5 if ord(i) > 127:
6 non_ascii += 1
7 if non_ascii > 3:

TypeError: ord() expected string of length 1, but int found

I have used the solution book, with same format, but i still get this error feedback. please i need help.

i will attach my work so far.Guided Project_ Profitable App Profiles for the App Store and Google Play Markets.tar (2.0 MB)

please i need guidance on this.

it has been a long day for me, but i figured it out once more through the help of a friend.

def is_english(string):
non_ascii = 0

for character in string:
    if ord(character) > 127:
        non_ascii += 1
if non_ascii > 3:
    return False
else:
    return True

( This is the correct step i took for it. i was getting the error message because at the initial code, i had something like this. placing the if function for the non_ascii > 3 under the if function ord(character) > 127

for character in string:
if ord(character) > 127:
non_ascii += 1
if non_ascii > 3:
return False

and i made a mistake as well with assigning an int value to the variable name.
the corrected format is shown below.

andriod_english =
ios_english =

for app in andriod_clean:
name = app[0]
if is_english(name):
andriod_english.append(app)
for app in ios:
name = app[1]
if is_english(name):
ios_english.append(app)

explore_data(andriod_english, 0, 3, True)
print(’\n’)
explore_data(ios_english, 0, 3, True)

Thanks guys.

Thanks @Bruno for editing my former question.

2 Likes