word_line_dict={'abc': ['av', '202', '4140'], 'rcd': ['j00001', '42000', 'j400', '1mm', '440', '1adcmm', '1cmm'], 'lac': ['46', '62', 'm111cmm', '485', 'm111', 't0ta1', 'cmm'], 'halo': ['175', '1355', 'gnt10', '1380', 'gmb10'], 'asd': ['440', '1adcmm', '225000', '1cmm', 'c0unt']}
for keys in word_line_dict:
for val in word_line_dict[keys]:
if val.isnumeric() != True:
word_line_dict[keys].remove(val)
print(word_line_dict)
the output of this code is:
{'abc': ['202', '4140'], 'rcd': ['42000', '1mm', '440', '1cmm'], 'lac': ['46', '62', '485', 't0ta1'], 'halo': ['175', '1355', '1380'], 'asd': ['440', '225000', 'c0unt']}
i just cannot get why this code is not removing the words like 1mm,1cmm,t0tal,c0unt but running this same code again on the output list removes all these words, my question is why is it not doing it in the first one only?
what i tried:
for keys in word_line_dict:
temp_list=word_line_dict[keys]
for val in temp_list:
if not val.isnumeric():
word_line_dict[keys].remove(val)