I'm getting the right results but console giving me error


#1



I'm getting the right results but console giving me error of:

Oops, try again. The value for the original variable looks off, make sure that you entered a word containing only letters.


that's my code:
pyg="ay"
answer=raw_input("type an english word and hit enter")
if len(answer) > 0 and answer.isalpha():
word=answer.lower()
first=word[0]
new_word= word+first+pyg
new_word= new_word[1:len(new_word)]
print new_word
else :
print empty


Replace this line with your code.


#2

I believe the error is here:

You should be printing answer like:

print answer

Please ensure your indentation is right, though. :slight_smile:


#3

That's not his problem, it is suppose to be the variable new_word that is printed, it's just that he has two different values for it that's causing the problem.


#4

@coreslayer06380 Check this out:

You have two different values for new_word, and the second is faulty as well as the first. Let's figure out the right code. The instructions tell us to take all of the original input except for the first letter, which will technically be our variable "word" and store it with the variable "new_word", so far our code looks like this:

new_word= word[1:len(word)]

Then it tells us to add the first letter of the user's input and then the "pyg" variable, so our code should look like this:

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

Everything else is fine for your code (assuming you have correct indents), simply replace the two lines I have pointed out with the one above. Message me if you still don't understand why the code is how it is. Hope that helps! :slight_smile:

-- @chipjumper36731


#5

nope still the same thing


#6

@chipjumper36731 , I don't get you though, please.

@coreslayer06380 This is the full code. You can also see my initial suggested code. I tried it and it does the intended.

pyg = 'ay'

#User enters a word
answer = raw_input("type an english word and hit enter")

#Control
if len(answer) > 0 and answer.isalpha(): #If answer is not empty and contains only character strings
    word = answer.lower() #transforms answer to lower case
    first = word[0] #Indexes first character in word variable
    new_word = word + first + pyg #concantenates word, first and pyg variables
    new_word = new_word[1:len(new_word)] #Gets characters from 2nd to last"
    print answer #prints answer to console
else:
    print 'empty' #if first loop not true, prints this

#7

@coreslayer06380
our problem is simple you need to change instead of answer ---> original
the variable name supposed to be original (it is a matter of verifying the code if its written correct)

and also when you go to the else when return empty it doesn't appear as an error but try this input -> 5
as a non alphabetic input ... it does appear as an error ... (you need to return a string)
otherwise it will appear for the compiler as unidentified variable ....


#8

Well, your point of "original" than "answer" is right as the initial code in the editor show. But, whatever variable now, however consistent, will pass the exercise. I was following fellow learner's code to clearly explain things.

Try my suggested code out if in doubt. :slight_smile:


#9

the same when i tried the code "10.ending up" ... it didn't pass me to the next exercise

the code is almost correct ... 1. the variable name . 2. the return statement inside the else ....
i finished it already .... but i'll see your code :smiley: thanks


#10

You definitely did not use my exact suggested code.


#11

excuse me but I'm talking about the original code in the post .... not your code :slight_smile:
i check it also

Oops, try again.
The value for the original variable looks off, make sure that you entered a word containing only letters.

check it in "10.Ending Up " not on "11.Testing, Testing, is This Thing On? "


#12

Okay! :slight_smile:


#13

Can you show us your code now?


#14

Not so. It is what the instructions ask for. The following is perfectly valid.

maybe a bit drawn out, though. Minor.

The instructions ask us to create a variable, original. The OP uses answer which is not expected by the lesson checker.


#15

But then it would print the user's input right back to them, instead of the pyglatin translator one? Now I'm very confused.


#16

Sorry my bad, I made a mistake when analyzing the result of the code. Slams head against the wall.


#17

I guess it's been resolved!? :wink:


#18

Not until the OP says so. We're still waiting for a response.


#19

If referring to me, my last post was to @chipjumper36731 on the issue I believe you addressed; who isn't the OP.

Sure, still waiting for the OP's response. :slight_smile:


#20

Hi everyone,

We have an interesting discussion going here.

An important part of the discussion process is the testing of each other's code. To aid that testing, we should make sure that our code is formatted when we post it, so that others can see details such as indentation, as well as to copy and submit that code for testing. While screen shots do display indentation, actual formatted text is best for copying and pasting.

See How do I format code in my posts?.

What I generally do is select and copy my own code and paste it into an external text editor, such as TextWrangler, Notepad, or another plain text editor, in order to preserve it, so that it can be restored later. Then, I can copy the user's code in order to experiment with it. At the end of the session, I can select and copy my own code, and then restore it on the appropriate exercise page.

When revising and testing our own code and that of others, we should sometimes refresh the page. Without our doing that, values of variables that have been removed from the code may still remain in memory, due to Codecademy's system for managing memory. The message reported in the original post relates, in part, to that issue. @coreslayer06380 must have had the variable, original intact at some time during an editing session, but then changed its name to answer. Since the page had not been refreshed, the submission correctness test (SCT) tested the value of original and found that it was not what it should have been.