4 examples of 'python program to find uncommon words from two strings' in Python

Every line of 'python program to find uncommon words from two strings' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
25def uncommonFromSentences2(self, A, B):
26 count = {}
27 for word in A.split():
28 count[word] = count.get(word, 0) + 1
29 for word in B.split():
30 count[word] = count.get(word, 0) + 1
31
32 return [word for word in count if count[word] == 1]
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

93def findCommonSubstring(strings):
94 substr = strings[0]
95 for string in strings:
96 for index in range(len(string)):
97 if substr[index] != string[index]:
98 substr = string[:index]
99 break
100 return substr
127def str_common_word_string_only_dld(str1, str2):
128 m = 0
129 for word in str1.split():
130 if len(word)>1 and len(re.findall(r'\d+', word))==0 :
131 for word2 in str2.split():
132 if dld(word,word2)<min(3,max(len(word)-3,1)):
133 m = m + 1
134 return m
80def words(a, b, c, d):
81 return a + s + b + s + c + s + d

Related snippets