My PygLatin program doesn't work as it must to! I can't figure out where I did wrong


#1



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


It shows me that everything I've done is correct but when I enter the word ''table'' in the console to try out my program it doesn't make it "ayablet"! It just returns table. Where am I wrong?


Replace this line with your code. 
pyg = 'ay'

original = raw_input('Enter a word:')

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


#3

Not quite how the translator is suppose to work. I think you mean this:

new_word = word[1:len(word)]

You can also simplify a bit of your code:

to this:

new_word= word[1:len(word)] + first + pyg

#4

use chipjumper36731's code and change the last line under 'if' to 'print new_word' as opposed to 'print original'


#5

like this :slight_smile:
pyg = 'ay'

original = raw_input('Enter a word:')

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


#6

Oh yes! I missed that. Whoops! :sweat_smile:


#7

HI i need help!!

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

print 'Welcome to the Pig Latin Translator!'

Start coding here!

my_variable = "original"
original = raw_input("Enter a word:")
print "original"

is the program correct.. or shouldn't i use print "original"


#8

Hi @balasubramanianrajav,

They told you to print original as the variable, so this line is completely unnecessary:

Delete it. And your print statement isn't working because of the quotes around original. This:

Will print the word original as a string as you put quotes around it. I suppose you mean to do this:

print original

Which will print the value of the variable original, as stated by the instructions. That should fix your code, and next time, make a new post instead of adding a different problem to a post.

Hope that helps! :slight_smile:

-- @chipjumper36731


#9

Thank your ... from next time on-wards i shall try posting a new link..

The output of the program doesn't change

Welcome to the Pig Latin Translator!
Enter a word: python
python
None

is the program correct


#10

Yup, that seems good for now. :slight_smile:


#11

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