Python Forum
NameError: name 'lst' is not defined - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: NameError: name 'lst' is not defined (/thread-17877.html)



NameError: name 'lst' is not defined - Jmekubo - Apr-27-2019

Guys Kindly help identify this error.

# clean tweets
def remove_pattern(input_txt, pattern):
    r = re.findall(pattern, input_txt)
    for i in r:
        input_txt = re.sub(i, '', input_txt)        
    return input_txt
def clean_tweets(lst):
    # remove twitter Return handles (RT @xxx:)
    lst = np.vectorize(remove_pattern)(lst, "RT @[\w]*:")
    # remove twitter handles (@xxx)
    lst = np.vectorize(remove_pattern)(lst, "@[\w]*")
    # remove URL links (httpxxx)
    lst = np.vectorize(remove_pattern)(lst, "https?://[A-Za-z0-9./]*")
    # remove special characters, numbers, punctuations (except for #)
    lst = np.core.defchararray.replace(lst, "[^a-zA-Z#]", " ")
return lst



---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
cell_name in async-def-wrapper()

NameError: name 'lst' is not defined



RE: NameError: name 'lst' is not defined - Yoriz - Apr-27-2019

I would expect you to be getting
Error:
SyntaxError: 'return' outside function
as return lst is not indented into the end of the function clean_tweets


RE: NameError: name 'lst' is not defined - Jmekubo - Apr-27-2019

thanks i hadnt seen that