Print all the non | Function to print all the non - repeating words from the two given sentences ; Concatenate the two strings into one ; Iterating over the whole concatenated string ; Searching for the word in A . If while searching , we reach the end of the string , then the word is not present in the string ; Initialise word for the next iteration ; Driver code
def removeRepeating ( s1 , s2 ) : NEW_LINE INDENT s3 = s1 + " ▁ " + s2 + " ▁ " NEW_LINE words = " " NEW_LINE i = 0 NEW_LINE for x in s3 : NEW_LINE INDENT if ( x == ' ▁ ' ) : NEW_LINE INDENT if ( words not in s1 or words not in s2 ) : NEW_LINE INDENT print ( words , end = " " ) NEW_LINE DEDENT words = " ▁ " NEW_LINE DEDENT else : NEW_LINE INDENT words = words + x NEW_LINE DEDENT DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s1 = " I ▁ have ▁ go ▁ a ▁ pen " NEW_LINE s2 = " I ▁ want ▁ to ▁ go ▁ park " NEW_LINE removeRepeating ( s1 , s2 ) NEW_LINE DEDENT