首页 > Python:"make sure you entered a word containing only letters."

Python:"make sure you entered a word containing only letters."

根据codecademy要求写的代码这样的:

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    newword = word + first + pyg
    newword = word[1:len(newword)]+first+pyg
    print newword
else:
    print 'empty'

s="Charlie"
print s[0]
print s[1:4]
print s[1:len(s)]

然后一直提示:

Oops, try again. The value for the original variable looks off, make
sure that you entered a word containing only letters.

请求解惑啊,万分感谢!!!


我想你输入的是不是纯字母字符,不是字母字符,转换大小写的时候会出问题的。


make sure that you entered a word containing only letters.

有道翻译:确保你进入一个单词只包含字母。

【热门文章】
【热门文章】