Aug-01-2020, 09:38 PM
(This post was last modified: Aug-01-2020, 09:44 PM by deanhystad.)
This is a list comprehension. It is a compact way of writing this:
temp = [] for word in tokens: if word.isalpha() temp.append(word) tokens = temp
tokens = []
says the resulting list is assigned to "tokens".[word for word in tokens]
says the list is going to be made up of words from the original "tokens".if isalpha(word)
says only include words that are "isalpha".