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

1 Answer

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

print(set(str1) | set(str2)) # letters in str1 or str2 or both


     
     
     
'''
run:
     
{'d', 'n', 'a', 'e', 'j', 'l', 'f', 'm', 'b', 'c', 'g'}
   
'''

 



answered Feb 20, 2023 by avibootz
edited Feb 20, 2023 by avibootz
...