I'm trying to remove periods, commas, single and double quotes from the end of each string. Each string is part of a list of strings
string_list= ["cars." , "red" , "orange," , "man'" , "thus:"]
desired_output --->["cars" , "red" , "orange" , "man", "thus"]
I tried using a list comprehension, but I keep getting a list of booleans rather than the desired output:
desired_output = [sub[:-1] =='' for sub in string_list[-1] if sub[:-1]== '.' or ',' or '"' or "'" or ':' or ';' ]
not the output I want, but it outputs as :
[True, True, True, True, True]
But I think this is due to a broader point that I don't understand the ways to format the syntax, ie, which way of formatting a list comprehension will output a list of booleans, which will output the desired effect. It would be very much appreciated if a generic scheme for the types of syntax for list comprehension could be included in an answer given.