Function to check if characters are English

Screen Link:

My Code:

def echeck(a_string):
    for character in a_string:
        asci = ord(character)
        if asci > 127:
            return False
        else:
            return True

echeck('Instachat 😜')
echeck('爱奇艺PPS -《欢乐颂2》电视剧热播')

What I expected to happen:

I expected the output to be False, and require my code to be edited to work better with English names with more characters. Seems to be working very well but the exercise said I should run into problems.

What actually happened:

True
False

Not sure why this is happening, my code is a little less efficient than the solution notebook but seems to otherwise be identical. Am I missing something obvious here? Function seems to properly output false in app names with other non-English characters.

hi @arvinabedi

Have you referred to this DQ Article ?

It may help you understand the code better.

Oh thank you so much, that is very helpful. Sorry I didn’t find that on my own, I’ll search harder next time. The community is just so helpful it’s hard to resist asking a question some times haha.

Thanks!

1 Like