How to get only characters from str1 or str2 but not in both with Python

1 Answer

0 votes
str1 = "acdgjln"
str2 = "bcefglmd"

print(set(str1) ^ set(str2)) # letters in in str1 or str2 but not both


     
     
     
'''
run:
     
{'m', 'b', 'f', 'e', 'a', 'n', 'j'}
   
'''

 



answered Feb 20, 2023 by avibootz
...