Python program that Displays which Letters are in Two strings but not in Both














































Python program that Displays which Letters are in Two strings but not in Both



str1=input("Enter the foremost string: ") #Asking the user to enter the first string
str2=input("Enter the second string: ") #Asking the user to enter the second string
result=tuple(set(str1)^set(str2)) #Two strings are converted to sets and XOR operation takes place between them
#result is stored in the form of tuple
for i in result:
print(i)


Output:
Enter the foremost string: Cppsecrets
Enter the second string: secrets
C
p

Comments

  • Aditya
    9-Sep-2019 11:19:14 AM
    s1=raw_input("Enter first string:")
    s2=raw_input("Enter second string:")
    a=list(set(s1)^set(s2))
    print("The letters are:")
    for i in a:
    print(i)