I have a list that looks like this separate=[[\'I\',\'wnet\',\'to\',\'the\',\'ma
ID: 3539440 • Letter: I
Question
I have a list that looks like this separate=[['I','wnet','to','the','mal,'],['and','bouht','a','new','shirt.'],['What','did','you','do','todya?']]
I'm going to run this through a program which will identify the misspelled words and replace them with the correct word but the list of words in the Webster Dictionary that I am using only uses lowercase letters- can I temporarily change all of the letters to lowercase but then in the end return the original upper and lower case words?
I know about str.upper() and str.lower() and set.capitalize
It seems like I want to use something like str.capwords() but inversely... I want to split the list into words(already done) and then make capital letters lower case.
Explanation / Answer
from numpy import ndarray
separate=[['I','wnet','to','the','mal,'],['and','bouht','a','new','shirt.'],['What','did','you','do','todya?']]
separatenew=ndarray((len(separate),),list)
for i in range(len(separate)):
a=[]
for j in separate[i]:
a.append(j.lower())
separatenew[i]=a
print separatenew
for i in range(len(separate)):
for j in range(len(separate[i])):
separatenew[i][j]=separate[i][j]
print separatenew
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.