Why should I Check Myself?


I feel like I am missing something. (And if you can't see the colon, it's there, it doesn't work)


Oops, try again. Oops! Did you accidentally delete the variable called original?
File "python", line 7
if: len(original) > 0:
SyntaxError: invalid syntax

I hoped it would work, but it didn't.

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
raw_input("Enter a word:")
original = raw_input('Enter a word:')

if: len(original) > 0:
    print original
    print "empty"


By the way, the variable "Original" is there, but it says it doesn't. :sweat: :cold_sweat:
Whams head agenst desk. :slight_smile:


Part of your code is redundant and does nothing, I would recheck it.

A hint is that your using a function that returns a value but you are not capturing that data at least one time in your code.


I don't get it. Check what?
(No offence)
I am only 10.


raw_input() is a function so when used returns some data. You have used it one time and it does not capture the data at all.

When you use a function if you need the data ensure that you place the data into a container such as a variable.

var = raw_input("")

Doing this will ensure that you can use the data later.

After that double check your code to ensure you followed the syntax of the language.


Ensure you read your error message. That is a critical point.



I had a similar error and I got somewhat believable answer.

another thing I noticed in your code is, semicolon (:slight_smile: at if statement should come at the very end,
here is my code:

Start coding here!

original = raw_input ("Enter a word:")

if len(original) > 0:
print (original)
print "empty"

hope it helps you ..


Didn't work. Sorry. :sob:
Have a look.
print 'Welcome to the Pig Latin Translator!'

Start coding here!

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


There is still redundant code in there that is just floating around doing nothing productive.

Example Code:

original = raw_input("Enter a word: ")
if original:  # An empty string is equal to false in python, as such no need to check length

That is the meat and bones of what you need to do right there.

Break down your problem and create simple instructions you can give the computer.

1. Get a word from the user, assign this word to a variable for later use.
2. Check if a word was input
3. Print a value based on if a word was entered or not

As you can see I followed this list of instructions I wrote for myself and it worked out great.

If you need any additional information or help feel free to ask.


THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It's perfect!!!!!!!!!!!!!!!! :relaxed::relaxed::relaxed::blush::stuck_out_tongue_winking_eye:


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