I would appreciate some help. I have a list of lists. The list containing all lists is called all_lists. In the lists of all_lists are strings. I want to apply a method on the text of each string in each list.
list_in_list = all_lists[0] #prints first list
string_in_list = list_in_list[0] #prints string in first list
I want to create a for loop which will allow me to alter all the strings with a method, and put them back in lists, and puts all lists back in the all_lists. This is what I have for now:
new_list = []
for i in range(len(all_lists)): # all lists
list_in_list = all_lists[i] # separate lists from all_lists
for j in range(len(list_in_list)): # every list in all_list
string_in_list = line[j] # separate string from list
new_string = decontracted(string_in_list) # apply the method on string
new_list.append(new_string) # put new string back in a list
I am unsure how to put every list back in a list containing all lists. Can anyone help me do this?
Example if the method was to capitalize every string:
from:
[['list one'],['list two'],['list...'],['list n']]
to:
[['LIST ONE'],['LIST TWO'],['LIST...'],['LIST N']]