Hi,
I’m on 7th mission Removing Non-English Apps on Guided Project: Profitable App Profiles for the App Store and Google Play Markets.
When i try to create the function to check whether these app names are detected as English or non-English, i’m facing an issue of the logic of the code.
What is the different of logique between the 2 codes of for Loops below please ?
- On the first code, the line**“return True”** is indente on if clause
- On the second code, the line “return True” is indent on For Loops.
but when i run then first code, he make the loop juste for the first character and not for all.
can you explain me the logic and why he don’t loop for all the String please?
Screen Link:
My Code:
def is_english(a_name):
for val in a_name:
if ord(val)>127:
return False
return True
print(is_english('Instagram'))
print(is_english('爱奇艺PPS -《欢乐颂2》电视剧热播'))
print(is_english('Docs To Go™ Free Office Suite'))
print(is_english('Instachat 😜'))
What I expected to happen on the result:
True
False
False
False
False
What actually happened:
True
False
True
True
True
solution Code:
def is_english(a_name):
for val in a_name:
if ord(val)>127:
return False
return True