我已经创建了一个列表(如下所示)。字符串长度为6个字符,但len返回的是1而不是6,我不明白为什么。 problem code and output
Motifs = [['AACGTA'],
['CCCGTT'],
['CACCTT'],
['GGATTA'],
['TTCCGG']]
#print(Motifs)
#count = {"A":[],"C":[],"G":[],"T":[]}
#print(count)
stringlenght = Motifs[0]
print(stringlenght)
k = len(stringlenght)
print(k)
#k should be 6 but is printing as 1
n = len('AACGTA')
print(n)
#n which is the same as Motifs[0] prints properly as 6
这是因为
Motifs[0]
也是一个列表。您可以执行k = len(stringlength[0])
,也可以修改Modifs
:然后它就起作用了
相关问题 更多 >
编程相关推荐