Change of contents of the list elements
-
I want it.
mas = ['1', '2.0', '3,0', '4%', '5.0%', '6,0%', 'seven1', 'eight.', 'nine,', 'ten%', ',11', '12,', '...', '.13', '14.', ''] n = True
Get it.
mas = ['1', '2.0', '3.0', '4', '5.0', '6,0', 'seven1', 'eight.', 'nine.', 'ten', ',11', '12,', '...', '.13', '14.', '0'] n = False
All ',' replace '.'
All '%' to delete
All '' replace '0'
variable n accepts False if the variable list contains letters
variable n accepts the False value if the variable list does not contain figures
variable n takes the False value if the variable list starts or ends on '.'
-
mas = ['1', '2.0', '3,0', '4%', '5.0%', '6,0%', 'seven1', 'eight.', 'nine,', 'ten%', ',11', '12,', '...', '.13', '14.', ''] n = True mas = [el.replace(',', '.').replace('%', '') or '0' for el in mas] for el in mas: if el[0] == '.' or el[-1] == "." or set(el)-set("0123456789."): n = False break