Word Comparison
in IT Support ·
Michelle Bennett5 said:Benjamin Brooks2 says:
I've never touched Python before, but I figure it would go something like this...
c=0
istaslova=""
sentence=input("Enter the first sentence: ")
sentence2=input("Enter the second sentence: ")
for i in range(len(sentence)):
for j in range(len(sentence2)):
for c1 in range(len(istaslova))
if sentence2.find(sentence)********* if it found the same letter in both words
if istaslova.NOTfind istaslova = istaslova + ......c=c+1****** if it DIDN'T find the letter in "istaslova" already, then add the letter
print("Duplicate letters:",istaslova)
print("Total count:",c)
It’s not gonna work like that. Check post #3; I already went over this there.
You need some kind of status matrix for every position in that first word—something to track what's been used up, right?
Fine, here's my first attempt at Python
Python C = 0
a = "Benjamin Brooks2"
b = "Michelle Bennett5"
common_chars = ""
for x in a:
- for y in b:
-- if x == y:
--- if x not in common_chars:
---- common_chars = common_chars + x
---- Python C = 0
print(c)
********************
I don't see any matrices here... maybe something else is going on at your event horizon, because I didn't even use "Used" 🤔
EDIT: Okay, I get what you mean about the dashes now