Hello everyone,
So, I have two different code blocks to remove non-english apps from the data. First one is a code I wrote to try myself and the other is from the answers provided. As a result I expect both of them to do the same thing. However, my code returns a data with 9615 rows even though the answer provided returns a data with 9614 rows. I can’t understand what might be the reason of this difference. Can you please help?
The code i wrote:
First i create a duplicate data to compare results.
android_clean2 = android_clean
and I create a for loop to delete non-english rows instead of creating a new list:
for count, row in enumerate(android_clean2):
name = row[0]
non_ascii = 0
for char in name:
if ord(char) > 127:
non_ascii += 1
if non_ascii > 3:
del android_clean2[count]
The answer provided:
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
android_english = []
for app in android_clean:
name = app[0]
if is_english(name):
android_english.append(app)