I need to add the function within the print function to a variable to be calledd to be printed only from the variable name.
My code –
for w in processed_H2_tag: print(lemmatizer.lemmatize(w.lower(), pos=wordnet.VERB))
Expected – Print(output)
"Output" is to be defined
>Solution :
You mean how to instead of printing get all the values into a list which you can then print?
You can do that with a list comprehension:
output = [lemmatizer.lemmatize(w.lower(), pos=wordnet.VERB) for w in processed_H2_tag]
Or if you prefer a classic for loop:
output = []
for w in processed_H2_tag:
output.append(lemmatizer.lemmatize(w.lower(), pos=wordnet.VERB))