This code is wrong


#1

The result is correct but when I input a word with uppercase letters
the letters appeared uppercase and not lower case

pyg = 'ay'
word = original.lower()
first = word[0]

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
else:
    print 'empty'

#2

that is because the conversion to lowercase is before you store the user input in original, that doesn't work.


#3

Can you rephrase that in a more human language?


#4

this line:

word = original.lower()

original is not yet defined, you define it here:

original = raw_input('Enter a word:')

how can convert something to lowercase which you haven't defined yet

In human language: give me the thing. If i haven't defined the thing yet (original) how can you give it to me? (convert it to lowercase)


#5

Got it. Makes sense.
Like this?

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

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

It still lets me go on to thenext lesson but does not eliminate the Capital letters


#6

i really recommend to revisit this exercise, it tells you to nest the case conversion and getting the first letter inside the if statement


#7

No it doesn't
This is the first lesson of the link you sent me:

Break It Down
Now let's take what we've learned so far and write a Pig Latin translator.

Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take:

Ask the user to input a word in English.
Make sure the user entered a valid word.
Convert the word from English to Pig Latin.
Display the translation result.
Instructions
When you're ready to get coding, click Save and Submit. Since we took the time to write out the steps for our solution, you'll know what's coming next!


#8

no, the url i provides is of word up, anyway, here are the instructions;

Inside your if statement:

Create a new variable called word that holds the .lower()-case conversion of original.Create a new variable called first that holds word[0], the first letter of word.

you didn't nest this inside your if statement


#9

WHICH LINE?

You're not telling me which line
WHAT DOES IT MEAN "INSIDE YOUR IF STATEMENT?

WHY DO YOU PEOPLE INSIST ON MAKING SOMETHING THAT IS SUPPOSED TO BE EASY, DIFFICULT?
I PUT THE STATEMENTS EVERYWHERE AND IT STILL IS INCORRECT.

this is the most user unfriendly lesson I have ever taken.

It tells me that I've made a mistake but refuses to explain to me HOW to fix the mistake.


#10

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

if len(original) > 0 and original.isalpha():
    # declare word here
    # declare first here
    print original
else:
    print 'empty'

see the comments i posted in the code above, that is what inside the if statements means.

if statement shouldn't be new? And nesting something inside an if statement neither?

programming is absolutely not easy, it can be frustrating and difficult

the errors codecademy gives you are easy to read, compared to what the interpreter gives you. Or even worse: a compiler. Those error messages are fun


#11

I put them there and I still get an error message.
pyg = 'ay'

original = raw_input('Enter a word:')

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


#12

this line:

first = "word"[0]

you want the first letter of the word variable, not a string word


#13

What about it?
THat's what's in there!!


#14

but by using quotation marks, you converted word into a string, while it was (and should be) a variable.


#15

You have word = original.lower()
And then below you have first = "word"[0]
the commas around word turn it into a string (I think?)
you don't want it to be a string!

(P{lease correct me if wrong as I a noob! ) :grin:


#16

See?
This is what I'm talking about.
You show me where the mistake is but don't explain what the mistake is and how to fix it until I ask again.
That's the problem with this whole lesson.
It tells me where the problem is but no clues as to how to fix it.

I understand that in real life no one will tell me where the mistake is and how to fix it.
But at this point there should be some understanding to people who genuinely want to improve their lives.

What this lesson is doing is making me fall into the belief that I will never be able to grasp this.


#17

pyg = 'ay'

original = raw_input('Enter a word:')

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

print original

else:
print 'empty'


#18

the clue is actually in my answer, by adding the quotation marks you made the variable a string, thus reversing the logic, removing the quotation marks would make it a variable again.

strings and variables are the first 5 lessons, and more later on. At sort point assumptions about basic understanding should be possible


#19

So in your opinion this code is correct?

pyg = 'ay'

original = raw_input('Enter a word:')

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

print original

else:
print 'empty'


#20

yes, this is the correct code