Check Yourself....Some Morwe


#1



original = raw_input("Enter a word:")
if len(original) > 0 and original.isaplha():
print original
else:
print "empty"

Welcome to the Pig Latin Translator!
Enter a word: KGH
Traceback (most recent call last):
File "python", line 5, in
AttributeError: 'unicode' object has no attribute 'isaplha'

How to proceed? It shows the same error.


Replace this line with your code.


#2

After this line original = raw_input("Enter a word:")
you need to put an empty string. original = " "


#3

original = raw_input("Enter a word:")
original = ""
if len(original) > 0 and original.isaplha():
print original
else:
print "empty"

I did this but still it shows this error.

Oops, try again. Did you remember to use .isalpha() in your code?


#4

Your code seems correct maybe its your indentation if not that just try refreshing your browser.


#5

Wait I've seen your error you typed in original.isaplha(): instead of original.isalpha():


#6

What is the difference between this original.isaplha():
and this original.isalpha(): ??


#7

Thanks!!
It's done.
Code runs successfully.
But atlast just tell me why we have used original = "" ?


#8

original.isalpha(): is a function used to check if the input has letters.
what you wrote--original.isaplha(): was a typo because there is no function called original.isaplha():.


#9

Because the user's input is a string we store what the user inputs into an empty string. Hence original = ""


#10

Cool!!
I got it. Thanks


#11

You're welcome. :+1:


#12

Ok, my code is this:

raw_input("Enter a word:")
original = ""
if len(original) > 0 and the_string.isalpha():
print original
else:
print "empty"

No matter what I input I get the result:

empty
None

codeacademy keeps telling me I'm right, no errors or anything, but that's clearly wrong. It should be printing the word I typed, right? As long as it's all alpha?

EDIT I'm unable to edit this correctly, but I have "print" indented both times, nothing else indented.


#13

You only stored an empty string into original so len(original) > 0 will always be FALSE(because ""'s length is 0) and hence will never print your input. Reason is, you aren't storing your input anywhere (is it supposed to be stored in original?).

Another thing: the_string.isalpha(). What is the_string? You never defined what it is. Is it some random word? An input? Should it be original as well?


#14

Ok thank you.

This still isn't working but does it at least make more sense?

raw_input("Enter a word:")
original = raw_input()
if len(original) > 0 and original.isalpha():
print original
else:
print "empty"


#15

Why not combine this to one line? You have two raw_inputs now.


#16

Apologies, I had to leave earlier.

That worked!!!

Now the code is:

original = raw_input("Enter a word:")
if len(original) > 0 and original.isalpha():
print original
else:
print "empty"

Thank you so much!!!!! This is my very first attempt at learning code. I really dig it!


#17

word = raw_input("Enter a word:")
print word
original = raw_input('Enter a word')
original=""
if len(original) > 0 and original.isalpha():
print original
else:
print "empty"
help, what 's wrong with my code


#18

But we already store the user's input in original = raw_input, so y we need to store this in empty string?


#19

No that line wasn't necessary


#20

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Enter a word:")
if len(original) > 0 and original.isalpha():
print original
else:
print "empty"

Why this code is not runnig?

thanks for reply.