我目前正在努力解决这个概念。
对不起,我一开始不清楚。我的输出是从orig_list中的单词打印每个字母。但是在我的程序中,不是停止在orig_list的最后一个单词中的最后一个字母(s),而是从头开始
alphabet = 'abcdefghijklmnopqrstuvwxyz'
orig_list = [ "bat", "act", "cat", "rat", "abs" ]
for i in alphabet:
for j in orig_list:
for l in j:
print(l)
我将在下面提供输出。请让我知道我在做什么错。
b
a
t
a
c
t
c
a
t
r
a
t
a
b
s
b
a
t
a
c
t
c
a
t
r
a
t
a
b
s
..... and so on
答案 0 :(得分:1)
您当前正在执行以下操作:
For every letter in the alphabet:
For every string in the list:
For every letter in the string:
print the letter
因此,每个字母中的每个列表项中的每个字母都打印一次。如果只想在列表中打印一次字符串,请删除循环的第一行。