<分区> 分区>
您好,我一直在尝试用 python 2.7 编写一个程序,该程序将单词作为输入并输出单词中的字母数。起初它在工作,但发生了一些事情,现在它不断地通过不属于 while 循环的第一行返回错误。 这是代码的一部分:
def number_of_letters(input):
nol = input.find(input[-1])
while input[nol:] != input[-1]:
nol = input.find(input[-1], input.find(input[-1] + 1)
nol = nol + 1
print nol
python 解释器通过我在 while block 之后尝试放置的任何内容不断返回语法错误(在本例中为“nol = nol + 1”) 我试过玩弄它但没有任何效果。请帮忙。 顺便说一句,如果有任何模块可以帮助这个程序,那就太好了,但我也想知道为什么这个不工作
