Skip to content

Commit 622e1e9

Browse files
authored
Update problem-5.py
1 parent 6666d71 commit 622e1e9

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

problem-5/problem-5.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
def findTheDifference():
2-
s = input("Enter the first string: ")
3-
t = input("Enter the second string: ")
4-
5-
for i in t:
6-
if i not in s:
7-
result = i
1+
def findTheDifference(s, t):
2+
3+
for i in range(len(t)):
4+
if s[i] != t[i]:
5+
result = t[i]
86
break
9-
else:
10-
if s.count(i) != t.count(i):
11-
result = i
12-
break
137

148
print("The difference is:", result)
159

1610
def main():
17-
findTheDifference()
11+
findTheDifference("abcd", "abced")
12+
main()

0 commit comments

Comments
 (0)