python 20课内嵌和闭包课后做一做 AAAxAAA找密码题目
str2 = '''ABSaDKSbRIHcRHGcdDIF'''length = len(str2)
countA = 0
countB = 0
countC = 0
for i in range(length):
if str2 == '\n':
continue
# |如果str1是大写字母:
# |-- 如果已经出现小写字母:
# |-- -- 统计后边的大写字母
# |-- 如果未出现小写字母:
# |-- -- 统计前边的大写字母
if str2.isupper:
if countB:
countC += 1
else:
countA += 1
#如果b是小写,只有当XXXaXXXb时,确定a符合,b待定
# 1.b前面必须为XXX,否则清零
# 2.若为XXXb???,则countB + 1,继续往后数
# 2,若为XXXab,则清零
# 3.若为XXXaXXXb,则记录a,以XXXb???继续记录
if str2.islower:
if countA == 3:
if countB:
if countC == 3:
print(str2,end='')
countC = 0
else:
countA = countB = countC = 0
else:
countB += 1
else:
countA = countB = countC = 0
我的代码如图,不明白为何无法实现,输出结果为空
isupper和islower后面漏了()。
页:
[1]