def english_only(string):
non_ascii = 0
for character in string:
if ord(character) > 127:
non_ascii += 1
if non_ascii > 3:
return False
else:
return True
print(english_only('testing'))
print(english_only('fdgsddgsgfd欢乐 颂 电 视剧热播'))
print(english_only('Instachat😜😜😜😜😜😜'))
print(english_only('Docs To Go™ Free Office Suite'))
print(english_only('😜testing'))
This is for the first python project where a function is used to remove non-english apps by returing True or False based on whether or not their is more than 3 non_english characters. This should return False for 2 strings at the bottom of the code. It is actually returning True each time. This is straight from the solutions manual, can someones help me understand why?
Hello Bruno,
I see your point, the bottom two strings are English but my concern is for the Instachat😜😜😜😜😜😜 and fdgsddgsgfd欢乐 颂 电 视剧热播 strings which are returning True when they should return False. I may have phrased this poorly before.
Maybe it’s just a bug on my end but I’m getting True for every string.
I’m fairly certain I was running into trouble because I added an extra indent to the second if statement and the else statement. I must have copied and pasted the wrong code, sorry for the trouble and thank you for the help.