Variable off?


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

Keep getting this error message no matter what I do. Everything works fine, but for some reason the isalpha() function is working backwards
This is my code right now, tried many different things that all perform the right task

pyg = 'ay'

original = raw_input("Enter a word:")
if original.isalpha() and x <= 0:
print 'empty'
else:
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
new_word = original
print new_word


#2

on this line

if original.isalpha() and x <= 0:

x is not defined

perhaps you want to do this len(original) instead of x
get rid of  the  original.isalpha() check  or if the user enters nothing it will still give an error

and you code itself will not give you the right output because of this line

new_word = original

no matter what you do you will only print out what the user entered because you are setting new_word to be that
Get rid of that line

See changes here


#3

Still same message
Those were just some things I added in to see if it would let me go on
Everything I've tried that actually gives an output just gives me that message and says I have to try again
The way I read it makes it seem like it doesn't think I'm writing a word


#4

I believe it could be a problem with the isalpha() function because when I run this code it returns "empty"

pyg = 'ay'

original = raw_input("Enter a word:")
if original.isalpha():
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print new_word
else:
print "empty"


#5

@irussotrapgod

I like to encapsulate stuff like this into a function because it makes it easier to work with I think.

EXAMPLE:

def pig_latin():
    try:
        original = str(raw_input("Enter a word")).lower()
        if (original and original.isalpha()):
            return original[1:] + original[0] + 'ay'
        else:
            raise TypeError
    except TypeError:
        print("You did not enter a valid response!")

#6

Oops, try again.
The value for the original variable looks off, make sure that you entered a word containing only letters.
Gives me that and returns None
Doesnt even run the code all the way
I'm thinking its some sort of glitch I don't know what else it could be


#7

Hahahahaha ok so I copied my old code and tried it in Chrome instead of firefox
Worked fine, move on to next lesson
Must have been a glitch with Firefox, thanks very much for your assistance though