How do I make all words in a list of words lowercase in python? [duplicate]
I'm trying to make all entries in my list dictionary lowercase but I cant figure out a way to do this
def get_entire_word_list():
dictionary = []
f = open("dictionary.txt", "r")
for x in f:
dictionary.append(x.strip('\n'))
f.close()
for x in dictionary:
x.lower()
for x in dictionary:
print(x)
return dictionary
This just won't do it :(
I tried
for x in dictionary:
x = x.lower()
but that wont do it either.
Thanks for any tips
If you have a list of strings, called dictionary, you can use a list comprehension like
dictionary = [x.lower() for x in dictionary]
to create a new list that contains only lowered cased string.