关于零基础入门第20讲内嵌函数和闭包动动手最后一题
a = '''ABSaDKSbRIHcRHGcdDIF'''length = len(a)
for each in range(3,length-3):
if a.islower():
i = 0
j = 1
h = 1
str1 = ''
str2 = ''
str3 = ''
while a.islower():
str1 = str1 + a
i += 1
changA = len(str1)
while a.isupper() and (each - j >= 0):
str2 = str2 + a
j += 1
changB = len(str2)
while a.isupper():
str3 = str3 +a
h += 1
changC = len(str3)
if changB == 3 and changC == 3:
print(str1,end='')
我是这样编的,结果也是abc,但是总是提示string index out of range,大家能帮我分析一下程序哪里出问题了吗?感谢 这和闭包有啥关系?? wp231957 发表于 2020-6-21 18:07
这和闭包有啥关系??
这节课的题目就叫内嵌函数和闭包,但我这里用的不是闭包的方法,我只想知道我的这个程序本身它存在什么问题,为什么会报string index out of range{:10_277:}
页:
[1]