remove_chars(s, chars_to_remove) that returns s with every character that appears in chars_to_remove deleted, leaving all other characters (including spaces) untouched.s = 'Hello, World!123', chars_to_remove = ',!123'
'Hello World'
Every character found in ',!123' is removed; letters and the space survive.
Convert chars_to_remove into a set for O(1) membership checks.
Build the result with a generator expression that keeps characters not in that set.