Question

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"

Was it helpful?

Solution

You should use original, not "original".

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

Over here:

len ('original')
     ^        ^

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top