main.py
Python
x
25
25
1
# Python3 program to find a list of uncommon words
2
3
# Function to return all uncommon words
4
def UncommonWords(A, B):
5
6
# count will contain all the word counts
7
count = {}
8
9
# insert words of string A to hash
10
for word in A.split():
11
count[word] = count.get(word, 0) + 1
12
13
# insert words of string B to hash
14
for word in B.split():
15
count[word] = count.get(word, 0) + 1
16
17
# return required list of words
18
return [word for word in count if count[word] == 1]
19
20
# Driver Code
21
A = "Edopedia Programming Tutorials"
22
B = "Learning from Edopedia Programming Tutorials"
23
24
# Print required answer
25
print(UncommonWords(A, B))