문제

print "Welcome to the English to Pig Latin translator!"

original = raw_input ("please, type a word") 

if len ('original') > 0 and original.isalpha():

    print original

else:

    print "empty"

What i'm trying to do is just make sure that the users input has more than 0 characters and make sure that are all letters, but when i write a number it prints the number, not "empty"

도움이 되었습니까?

해결책

You should use original, not "original".

"original" is a literal string, while original is a variable name.

Over here:

len ('original')
     ^        ^

다른 팁

You probably mean len (original) - otherwise it will always be true (you are calculating length of the string "original".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top