How to Display Different Letters between Two Strings in Python


Here let us see how to display letters that are not contained in two strings at the same time in Python.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

str1 = set(input("Please input the first string: "))
str2 = set(input("Please input the second string: "))
s = str1 ^ str2
print("The different letters in these two strings are: ")
for i in s:
    print(i, end="\t")

Output:

Please input the first string: apple
Please input the second string: Python
The different letters in these two strings are: 
o	P	t	n	y	h	l	e	p	a
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments