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
24 lines (19 loc) · 704 Bytes
/
answer3.py
File metadata and controls
24 lines (19 loc) · 704 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
def common(str1, str2):
str1 = str1.lower()
str2 = str2.lower()
list1 = []
list2 = []
punc = """!()-[]{ };:'"\,<>./?@#$%^&*_~"""
for i in str1:
if i not in punc:
list1 += i
for i in str2:
if i not in punc:
list2 += i
shared_letters = sorted(set(list1) & set(list2))
unique_to_str1 = sorted(set(list1) - set(list2))
unique_to_str2 = sorted(set(list2) - set(list1))
return ' '.join (str(e) for e in shared_letters), ' '.join(str(e) for e in unique_to_str1), ' '.join(str(e) for e in unique_to_str2)
str1 = input('Please type a word: ')
str2 = input('Please type a second word: ')
print(common(str1, str2))