def f345(a,b):
if len(a) != len(b) or len(a)<2:
return False
elif a == b and (a.find('aa') != -1 or a.find('bb') != -1):
return True
else:
l = []
for i in range(len(a)):
if a != b:
l.append(i)
if len(l) == 2 and l-l ==1:
return True
else:
return False
a=input('请输入第一个字符串:')
b=input('请输入第二个字符串:')
l1=len(a)
l2=len(b)
m=0
if l1!=l2:
print('Flase')
else:
for i in range(l1):
if a!=b:
m+=1
if m>2:
break
if m==2:
print ('Ture')
elif m==0:
for i in a:
m=a.split(i)
if len(m)>2:
print('True')
break
else:
print('Flase')
else:
print('Flase')
ouyunfu 发表于 2020-3-27 18:51
谢谢提示,已改
还是一样的错呢
March2615 发表于 2020-3-27 18:54
抱歉注释有点多,怕没考虑到某些情况
44 ms
塔利班 发表于 2020-3-27 19:38
解答错误
输入:a = "ab",b = "ab"
输出:True
预期结果:False
TJBEST 发表于 2020-3-27 20:43
来个没效率的
解答错误
输入:a = "abab", b = "abab"
输出:False
预期结果:True
whosyourdaddy 发表于 2020-3-27 21:16
def func360(a,b):
if len(a) != len(b):
return False
28 ms
BngThea 发表于 2020-3-27 21:23
输入 a = "ab",b = "ab" 出错
Herry2020 发表于 2020-3-27 21:41
c = "abcd"
d = "abcd"
def fun360(a,b):
缩进有点问题,帮你改了
Herry2020 发表于 2020-3-27 21:41
c = "abcd"
d = "abcd"
def fun360(a,b):
292 ms
旅途Z 发表于 2020-3-28 11:08
def switch_equal(str1, str2):
length = len(str1)
diff_list = []
输入 a = "",b = "" 结果有误
flamezyy 发表于 2020-3-28 13:22
解答错误
输入:a = "ab",b = "ab"
输出:True
预期结果:False
mdphd 发表于 2020-3-28 20:24
44 ms
l0stparadise 发表于 2020-3-28 20:48
48 ms
蒋博文 发表于 2020-3-29 09:59
60 ms
风魔孤行者 发表于 2020-3-29 10:33
解答错误
输入:a = "abcaa",b = "abcbb"
输出:True
预期结果:False
zltzlt 发表于 2020-3-29 13:12
输入 a = "ab",b = "ab" 出错
忘了检测完全一致的情况,已改
zltzlt 发表于 2020-3-29 13:08
解答错误
输入:a = "abab", b = "abab"
已修改
def fun360(a,b):
if len(a) != len(b):
return False
M = len(a)
index_arr = !=b]
if len(index_arr) == 2:
if a] == b] and a] == b]:
return True
else:
return False
elif len(index_arr) == 0:
if len(a) > len(set(a)):
return True
else:
return False
else:
return False
zltzlt 发表于 2020-3-29 13:19
解答错误
输入:a = "abcaa",b = "abcbb"
def f345(a,b):
if len(a) != len(b) or len(a)<2:
return False
elif a == b and (a.find('aa') != -1 or a.find('bb') != -1):
return True
else:
l = []
for i in range(len(a)):
if a != b:
l.append(i)
if len(l) == 2 and l-l ==1 and a] == b]:
return True
else:
return False
#每日一题 360
def strings(a, b):
answer = False
misNumbers = 0
misDigits = str()
if len(a) != len(b): pass
else:
for x in range (len(a)):
if a != b:
misNumbers += 1
misDigits += str(x)
if misNumbers != 2:
if misNumbers == 0:
for x in range (len(a)):
if a.count(str(a)) >=2:
answer = True
break
else: pass
else:
swapA1 = a)]
swapA2 = a)]
swapB1 = b)]
swapB2 = b)]
if swapA1== swapB1 and swapA2 == swapB2: answer = True
return answer