Pregunta

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"

¿Fue útil?

Solución

You should use original, not "original".

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

Over here:

len ('original')
     ^        ^

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top