我很确定我的程序有另一个愚蠢的错误,但我找不到它。我试图谷歌一段时间,但迄今没有结果。TypeError:类型'builtin_function_or_method'的对象在使用字符串时没有len()
我想要使用循环的len方法。我用它恰好在没有问题的程序不同的功能以同样的方式,但在这个功能我得到一个类型错误:
def longestPalindrome(DNA):
"""
Finds the longest palindrome in a piece of DNA.
"""
DNA = DNA.upper #makes sure DNA is in all caps
longest = ""
for x in range(len(DNA)):
for y in range(len(DNA)):
long = DNA[x:y+1]
if checkPalindrome(long) and (len(long) > len(longest)):
longest = long
return longest
DNA是一个字符串,checkPalindrome是较早的功能,它检查是否一块DNA是回文。