How can I know if my translator works properly?

It’s disbelief not unbelief. And I do not feel the need to ask questions w

that is up to you.

line 8 should be:

new_word = word + pyg

so that new_word becomes “appleay”. or is the double “a” intentional?

also, there’s no instructions to print new_word to see it’s new value.

that is the next exercise.

you could make a condition to check if the first letter equals 'a', its something to consider

I am also getting the same problem

I should get in lower case so what is he error ?

You convert lowercase, this conversion is successful, but you never print this.

Hi! The reason you’re getting an error is because you are using:

print original
When you should be using:
print new_word

You want to have your translator print the new (ie translated) word, instead of the original (ie input) word! Hope this helps! :slight_smile:

I seem to be encountering some kind of strange bug with this lesson. I made it all the way to the last step, but when I hit “run,” the loading icon shows and never stops spinning. I can type in a word and hit enter to test it, but even though I ended up showing the answer and having the lesson auto-complete with the correct solution and it says it’s correct and completed, it’s just returning the exact word I enter. So, for example, if I enter “test,” it just prints “test”.

1 Like

Can i see your code?

after slicing the new word, try writing new_word = new_word and then in the next line type print new_word. this does not fix the capitilization (atleast for me) but it fixes the translator

So My code goes like this

"
#all the things to make a pig latin is in the variables and making the string
original = raw_input(‘Enter a word:’)
pyg = ‘ay’
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]

if len(new_word) > 0 and new_word.isalpha():
print new_word
else:
print ‘empty’
"
So I tried the pig latin and it works if I put a word in there. But When I leave it Empty it has an error message
"
Traceback (most recent call last):
File “python”, line 5, in
IndexError: string index out of range
"
it seems the code still ask for the first letter input even If i already provide the if statement of “len(new_word) > 0”, how can I fix this code?

but this after attempting to to get the first letter from the string. So your sanity check seems to be too late. Thinking about it, shouldn’t you first check the input is valid before doing all kinds of manipulation?

pyg = ‘ay’

original = raw_input(‘Enter a word:’)

if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]

new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print "The PygLatin word is " + str(new_word)
else:
print ‘empty’

This is my code, let me know if it helps

My code looks identical to the solution, but when I click run, I get the correct phrase printed out, but the wheel keeps spinning and then the red X indicates I have not answered correctly. There is no error message:

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 new_word
else:
  print 'empty'

I don’t understand why this is the case, a friend of mine looked over the code and said it should be fine.
Thanks

1 Like

I don’t see any fault either. There are sometimes problems with raw_input, so maybe try to replace it with a string:

original = 'test'

see if that works

Hi, if you enter a word with numbers, the program then prints “empty” and stops, how would you make it prompt you to enter a different with without clicking run again?

You would have to implement a loop, which keeps running until you get valid input.

Very disappointed with this lection. Bugs everywhere that have been ocurring for 2 years long. I’ve used the exact same code as the solution and doesn’t works. Then, use the show solution button and doesn’t work again.

Here’s the code (Wow! it’s the same as the solution one -_-)
image
It never end’s executing and when it does, it does not add that ay at the end. This reminds me from another lesson, where when you finally could add the ay because the interpreter worked miraculously, then it said that you had to add hay. Embarrasing.

Now, in the case the interpreter actually works, then always prints me 'empty' instead of pointing me out the actual word with ay added. Not only that but very bad explained all the concepts along this part of the module.

Can only say that all along the module I haven’t compiled anything (even though having to use all the time the view solution, which exactly showed me the same code I did). I’m going to continue but this was a very regrettable experience.

I also been using Chrome’s w/o cache data. Nothing more to add I guess.

Lesson: Last module from the Project related with PygLatin.

1 Like

Seems to me we have the same functional code, yet it works on my raspberry pi with Chromium.

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
  print original
  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'

Enter a word:latin
latin
atinlay

1 Like