|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大神们,这道题我大概的思路是:将每个单词对应的行数都写出来,最后得到一组1111111111121223111213222 长度为25的字符串,然后将每个单词的长度的字符串截取出来去跟第一个比,如果中间出现任何不一样的就break,然后判断下一个单词。。。
但是,我看了半天,,应该是最后的标记的地方有点点问题,,但是看了半天不知道是哪有问题 ,还请大神们帮忙看看
'''美式键盘'''
words = ["Twitter", "TOTO", "FishC", "Python", "ASL"]
leng_ =[]
l1 = 'qwertyuiop'
l2 = 'asdfghjkl'
l3 = 'zxcvbnm'
last = ''#每个单词对应的计算机行数
answer = []
for word in words:
word = str(word)
for i in word.casefold():
if i in l1:
last = ''.join((last,('1')))
elif i in l2:
last = ''.join((last,('2')))
elif i in l3:
last = ''.join((last,('3')))
#找出每个单词对应的长度
for i in words:
leng = len(i)
leng_.append(leng)
flag = 0
for y in leng_:
word_ = last[:y]
last = last.removeprefix(word_)
print(y,len(last))
for j in range(len(word_)):
print(word_)
major = word_[0]
'''美式键盘'''
words = ["Twitter", "TOTO", "FishC", "Python", "ASL"]
leng_ =[]
l1 = 'qwertyuiop'
l2 = 'asdfghjkl'
l3 = 'zxcvbnm'
last = ''#每个单词对应的计算机行数
answer = []
for word in words:
word = str(word)
for i in word.casefold():
if i in l1:
last = ''.join((last,('1')))
elif i in l2:
last = ''.join((last,('2')))
elif i in l3:
last = ''.join((last,('3')))
#找出每个单词对应的长度
for i in words:
leng = len(i)
leng_.append(leng)
flag = 0
for y in leng_:
word_ = last[:y]
last = last.removeprefix(word_)
print(y,len(last))
for j in range(len(word_)):
print(word_)
major = word_[0]
if major != word[j]:
flag = 1
break
else:
continue
if flag == 0:
answer.append(words[leng_.find(y)])
print(answer) |
-
|