def consecutiveLetter(str):
x=0
flag=0
while(x<(len(str)-2)):
i=ord(str[x])
j=ord(str[x+1])
k=ord(str[x+2])
if((i+1)==j and (j+1)==k):
print("String has 3 consecutive letters")
flag=1
break
else:
x=x+1
if(flag==0):
print("String has no 3 consecutive letters")
当我在python中运行它时,它要求我输入consercutiveletters('then the word')。在
我只想输入这个单词,它会告诉我它是否有3个连续的字母。请帮忙!在
您可以这样简化
^{pr2}$consecutiveLetter
函数:相关问题 更多 >
编程相关推荐