Guided Project #1 (7/14): "is_english" function error

Screen Link:

My Code:
TypeErrorTraceback (most recent call last)
in ()
9 for app in ios:
10 name=ios[0]
—> 11 if is_english(name):
12 ios_english.append(app)

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

TypeError: ord() expected a character, but string of length 9 found

Other details:
I ran the code in the cell where you start by making a dictionary for english ios & android apps. The code eventually goes back one cell to run the function “is_english” and this is where the ios dataset runs into the error message mentioned above.

I don’t understand the error message. Isn’t the code supposed to check every character of the string, so why does it run into an error when confronted with a string (of length 9)?

Based on what you share -

9 for app in ios:
10 name=ios[0]

You use a for loop to loop through the app lists in ios. But then you use ios[0] inside that loop.

ios[0], depending on how ios is structured, would be the first list and not the name of the app that you want.

So, when you use is_english(name), your name is a list.

And then, in your is_english(string) function, you have

for character in string:

that string is a list and not the name of the app as you wanted.

So, you need to modify the following -

for app in ios:

so that name gets the app name based on app and not on ios directly.

Oops, got it. Thanks for the quick reply.