自己比较笨,从昨天思考到今天下午四五点,感觉0基础学python太难了啊啊啊啊!!
刚刚写好的代码str1 = '''AAAaBBBbCCC'''
count1 = 0
count2 = 0
length = len(str1)
for each in range(length):
if each < 3 or each > length - 3:
continue
if each == 3:
for l in range(1, 4):
if str1[each - l].isupper():
count1 += 1
continue
if each == length - 4:
for r in range(1, 4):
if str1[each + r].isupper():
count2 += 1
continue
if str1[each].islower():
if count1 != 3:
for l in range(1, 4):
if str1[each - l].isupper() and not str1[each - 4].isupper():
count1 += 1
if count2 != 3:
for r in range(1, 4):
if str1[each + r].isupper() and not str1[each + 4].isupper():
count2 += 1
if count1 == 3 and count2 == 3:
print(str1[each], end='')
count1 = 0
count2 = 0
|