forked from fenyx-it-academy/Class7-Python-Module-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswer3.py
More file actions
27 lines (19 loc) · 687 Bytes
/
answer3.py
File metadata and controls
27 lines (19 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#collecting inputs:
word1 = set(input("type any word: ").lower())
word2 = set(input("type another word: ").lower())
#shared letters as a sorted string
common = sorted(set(word1 & word2))
incommon_str = ''.join (list (map (str, common)))
#Letters unique to word 1 as a sorted string:
unique_to1 = sorted(set(word1 - word2))
unique1 = ''.join (list (map (str, unique_to1)))
#Letters unique to word 2 as a sorted string:
uinque_to2 = sorted(set(word2 - word1))
unique2 = ''.join (list (map (str, uinque_to2)))
#creating a list of the above strings
lst = []
lst += [incommon_str]
lst +=[unique1]
lst +=[unique2]
# extracting the requested output:
print("the output is:" + str(lst))