Remove characters from the first string which are present in the second string | Python 3 program to remove duplicates ; we extract every character of string string 2 ; we find char exit or not ; if char exit we simply remove that char ; Driver Code
def removeChars ( string1 , string2 ) : NEW_LINE INDENT for i in string2 : NEW_LINE INDENT while i in string1 : NEW_LINE INDENT itr = string1 . find ( i ) NEW_LINE string1 = string1 . replace ( i , ' ' ) NEW_LINE DEDENT DEDENT return string1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT string1 = " geeksforgeeks " NEW_LINE string2 = " mask " NEW_LINE print ( removeChars ( string1 , string2 ) ) NEW_LINE DEDENT