PYGLATIN Ending Up


#1

:rice_ball:

https://www.codecademy.com/courses/learn-python/lessons/pyglatin/exercises/ending-up?action=lesson_resume

the error is: The value for the original variable looks off, make sure that you entered a word containing only letters.

I don’t know if I am doing stuff wrong or if it’s the new course format or what, but I am not figuring this out

```python

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
else:
print ‘empty’

<do not remove the three backticks above>
:rice_ball:

#2

Under the line where you declared new_word add this line,

new_word = new_word[1:len(new_word)]

In the next lesson you will add a print statement just beneath that line, before the else:.


#3

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[1:len(new_word)]
else:
print ‘empty’

It now says my code didn’t run to end and the console said
Traceback (most recent call last):
File “python”, line 8, in
NameError: name ‘new’ is not defined


#4

Here:

new_word = new[1:len(new_word)]

Should be…

new_word = new_word[1:len(new_word)]

#5

now it says
File “python”, line 3
original = raw_input(enter a word:)
^
SyntaxError: invalid syntax


#6

It’s just being weird now.


#7

It’s not being weird, you are receiving a syntax error, because you have used improper syntax in this line:

original = raw_input(enter a word:)

enter a word: should be a string. This means it should look like this…

original = raw_input("enter a word:")

#8
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:] + first + pyg
  print new_word
else:
    print 'empty'

worked for me, have i fluffed it or is this a valid attempt, how important is it to use " [1:len(new_word)] "


#9

Not at all unless following instructions to the letter is considered important. For best results complete the exercise on spec, then play around with it once your pass the lesson.


#10
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'`

my fixed version.


#11

Perfect! Now feel free to write all the variations you wish. For instance, a combined string expression, formatted:

    print "{:s}{:s}{:s}".format(word,word[0],pyg)[1:]

#12

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