I have been trying to fit the following list of words from a text file into one list comprehension:
file = open("Lincoln.txt", "r").read().split()
world_list = []
for v in file:
word_list.append(v.translate(str.maketrans("", "",string.punctuation)).lower())
for i in word_list:
if i != '':
world_list.append(i)
This is succesful, but I'm not sure how to include the second part of the for loop in that same list comprehension:
word_list = [v.translate(str.maketrans("", "",string.punctuation)).lower() for i,v in enumerate(word_list)]
Without the second part, I still get empty strings from my word extraction: