Python Forum

Full Version: NameError: name 'lst' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
thanks i hadnt seen that