我正在使用Python 3.4,并且在我的程序中收到错误消息“'wordlist is not defined'”。我究竟做错了什么?请用代码回复。Python v3查找最长的单词(错误信息)
该计划是找到最长的单词:
def find_longest_word(a):
length = len(a[0])
word = a[0]
for i in wordlist:
word = (i)
length = len(i)
return word, length
def main():
wordlist = input("Enter a list of words seperated by spaces ".split()
word, length = find_longestest_word(wordlist)
print (word, "is",length,"characters long.")
main()
您的问题的标题是不是很有用的信息... – 2015-02-24 04:00:48