In: Computer Science
IN PYTHON:
i have a list of strings:
['1,099', '1,749', '119', '129', '129', '13,299', '149', '15,299', '159', '159', '175', '179', '179', '186', '189', '189', '199', '2,549', '226', '257', '290', '3,755', '35,279', '390', '399', '399', '4,549', '415', '415', '498', '499', '499', '499', '499', '549', '60', '819', '849', '89', '89', '899', '899', '899', '899', '999']
and i want to remove the commas from each string containing a comma, and then convert each element to an integer. (for example, i have '1,099' but want 1099, and do this for every one)
b = ['1,099', '1,749', '119', '129', '129', '13,299', '149', '15,299', '159', '159', '175', '179', '179', '186', '189', '189', '199', '2,549', '226', '257', '290', '3,755', '35,279', '390', '399', '399', '4,549', '415', '415', '498', '499', '499', '499', '499', '549', '60', '819', '849', '89', '89', '899', '899', '899', '899', '999']
# splitting using comma
# joing using no delimeter
# coverting to integer
for i in range(len(b)):
b[i] = int(''.join(b[i].split(',')))
print(b)
# Please up vote