My program works, but still gets error


#1

Stuck at 10 Ending Up (Pyglatin)

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

My code works beautifully. BULLOCKS returns ullocksbay, bullocks returns the same ullocksbay. So I know it's returning lowercase.

But I still get OOps try again, word should contain the .lower()-case version of original.

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


#2

It took me awhile to see it but now I do. There is one very SMALL problem with your code but it shouldn't affect it but I think it is... The only difference between our codes (and mine worked when I did that exercise) is that after your line new_word = word[1:] I didn't use word as my next variable. I used new_word = word + first + pyg then print new_word because otherwise you are getting rid of the lowercase in theory, because you are resetting the variable word (with your existing code), even if for some reason BULLOCKS still results in ullocksbay. :wink: Also my code was a little different too so I just figured I would include it. (You may have to remove the strings to make it work on CC but I like how it looks this way better)

print 'Welcome to Sean\'s Pig Latin Translator!'

pyg = 'ay'
original = raw_input("Enter a word in English:")

if len(original) > 0 and original.isalpha():
    print "Your word in English: " + original
    word = original.lower()
    first = word[0]
    new_word = word + first + pyg
    new_word = new_word[1:]
    print "Your word in Pig Latin: " + new_word
else:
    print "empty"

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.