零基础20讲 动动手1题问题
本帖最后由 工程狗 于 2017-9-8 14:46 编辑str1 = '''输入的字符串'''
alf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
code = []
for each in str1:
if each in 'abcdefghijklmnopqrstuvwxyz':
position = str1.index(each)
if position>2 and position+3<len(str1) and (str1 in alf) and (str1 in alf) and (str1 in alf) and (str1 in alf) and (str1 in alf) and (str1 in alf):
code.append(each)
print(code)
我写的代码是这个,我知道我的逻辑错了,但是不知道为什么运行出来是很多字符串‘1‘的列表
题目没有描述清楚哈
但大概知道你的意思
是不是很多重复的字母,如果不想有重复字母在code里,我们可以再加判断:
if each not in code:
code.append(each)
来群吧,扒皮风群欢迎你
页:
[1]