全桥整流 发表于 2021-8-23 10:41:36

课后作业疑问

str1 = '''ABSaDKSbRIHcRHGcdDIF'''
i=0
list1=[]
l= len(str1)#有什么用?
for t in str1:
    list2=
    if t.islower():
      if list2 >= 0 and list2[-1]<l:
            if str1].islower() and str1].islower():
                a = 0
                for s in range(1,7):
                  if str1].isupper():
                        a += 1
                        if a == 6:
                            list1.append(t)
      
    i += 1
print(list1)


第4行有什么用?后面没有用到l。

柿子饼同学 发表于 2021-8-23 10:48:47

第 9 行用到了呀
这是指这个列表的长度

灰晨 发表于 2021-8-23 11:42:58

if list2 >= 0 and list2[-1]<l
这不就用到了吗
l= len(str1)
len()这个函数是用来求字符串长度的,这里l= len(str1)= str1的长度

全桥整流 发表于 2021-8-23 14:10:34

灰晨 发表于 2021-8-23 11:42
if list2 >= 0 and list2[-1]

哦哦,我以为那个是1来的
页: [1]
查看完整版本: 课后作业疑问