I need to replace the characters in a string for "(" if they´re unique and ")" if they´re repeated. this is the solution i´ve come up with:
text = "arandela replace= lambda x : ")" if re.search(rf"^.*({x}.*){{2,}}$",word) else "(" result = "".join((map(replace,text)))
it works fine until the input has a special character. is there a way to make it work?
Anonymous Changed status to publish May 14, 2021
Recent Comments