Could you please tell me how can I remove ")" from strings in a list without converting the list to a string? Example:
Input:
list =[
'ABDDDDC 1,000 IWJBCKNBCDVV',
'BDISJBJ 2,000 DBFIAJDBDIAJ',
'JDBISJB 5,000 AHSBIEFEWEFJ)', # there is a parenthesis at the end
'CONDDDD 7,000 4DJVBDISJEVV)'] # there is a parenthesis at the end
Expected output:
list =[
'ABDDDDC 1,000 IWJBCKNBCDVV',
'BDISJBJ 2,000 DBFIAJDBDIAJ',
'JDBISJB 5,000 AHSBIEFEWEFJ', # parenthesis is removed
'CONDDDD 7,000 4DJVBDISJEVV'] # parenthesis is removed
I know how to do it by converting list to str like following:
a = str(list)
a = a.replace(")","")
print(a)
However, since I need convert it to a dataframe later... I want to keep it as list. Please let me know if you need any clarificaiton for my question. This is my first time to post a question.
[item.replace(')', '') for item in list][item.rstrip(")") for item in list]if you only want to eliminate the")"at the end. And don't uselistas variable name, you're overriding a builtin function.