5. Check Yourself... Some More


#1


https://www.codecademy.com/en/courses/python-beginner-2W5v7/0/5?curriculum_id=4f89dab3d788890003000096#

I keep getting errors that say "Oops, try again. It looks like your code prints original ("ghost123") when original includes non-alphabetical characters"

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word:")
print original
empty_string = ""
if len(empty_string) > 0 and emptry_string.isalpha():
print empty_string
else:
print "empty"

I'm running the .isalpha() function, but it doesn't appear to work, even when I write it as empty_string.isalpha(empty_string): it still doesn't work. Am I missing something

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")
print original
empty_string = ""
if len(empty_string) > 0 and emptry_string.isalpha():
    print empty_string
else:
    print "empty"

#2

Hey bytecoder,

In line (what I think is 7) you've got "emptry_string.isalpha():"

Change that to "original.isalpha():" because you're trying to get "isalpha():" to examin the users input, not the empty_string variable. Also on the next line change "print empty_string" to "pring original". Print empty_string wouldn't print anything because it's empty. You want to print out the users input.

Also in line 7, you're comparing the length of empty_string to 0. You want to compare the length of original to 0. So instead of "len(empty_string)" you'd want "len(original)".

Hope this helps!


#3

I'm still getting the same error message when I run this

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word:")
print original
empty_string = ""
if len(original) > 0 and original.isalpha():
print original
else:
print "empty"

or I input this

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word:")
print original
empty_string = ""
if len(empty_string) > 0 and original.isalpha():
print original
else:
print "empty"


#4

Oh I see! Delete the first print original (The one not in the "if/else" code block). Then it should work!


#5

I deleted line 5 "print original" and it worked. Thanks ghughes13 for the advice, that helped clean up everything.


#6

This one works on me:

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word:")
print original
empty_string = ""
if len(empty_string) > 0 and emptry_string.isalpha():
print empty_string
else:
print "empty"