I am trying to learn functions in python, I come across a dead end for below problem where I have to write a function to take a list of strings as input, remove special characters and return a list with clean strings.
Code looks as below:
def cleanChar(a): a=[] b=[',','?','#','@','$','%','^','&','*','/'] out_list=[] for x in a: for y in b: if y in x: x=x.replace(y,'') out_list.append return out_list testq = ['#mahesh','%Po*hsi$','Iy&gdj'] test3=cleanChar(testq) print(test3) https://stackoverflow.com/questions/67293204/removing-characters-from-a-list-in-python-function April 28, 2021 at 11:07AMI get the out put as an empty list. What am I doing wrong here or what should have been my approach? Thanks in advance for the help.
没有评论:
发表评论