10/11 PygLatin Help me you're my only hope


#1

Okay I don't understand. What exactly am I doing wrong here? My coding is displayed below and the console keeps saying:
File "python", line 13
new_word = [1:len(new_word)]
^
SyntaxError: invalid syntax

and here is my coding:
pyg = 'ay'

if len("original") > 0 and "original".isalpha():
print "original"
original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word + first + pyg
s = "Charlie"
s[0]
s[1:4]
new_word = [1:len(new_word)]
print new_word

else:
print 'empty'


#2

Some of your code is out of order. Study the following and compare:

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'

Can you spot your errors, now?


#3

@mtf

I agree with you on the ordering but as you can clearly see his indentation is also off.

Also I hate how they wrote this course, they make you write it way more verbose then it needs. to be.

What you need to complete a pig latin translator is as follows,

  1. Move the first letter of the word to the end.
  2. Add 'ay' to the end of the new string of letter
  3. Word has to be 2 or more characters in length

Now that we have the instructions condensed you might have an easier time in getting the code to work.

Example:

original = raw_input("Enter a word:\n")
if original and original.isalpha():
    print(original[1:] + word[0] + 'ay'
else:
    print("You failed to make a valid entry.")

This might have not pass the course but it is all that is needed to generate words in pig Latin.

Also, you need to get some understanding that the indentation in python is vital, it allows the computer to understand when one word/sentence is finished. If you do not follow the syntax the computer will yell at you because you are speaking gibberish to it.

As always good luck.


#4

Lord Aizen thanks you, patricians.


#5

I make it a point to forego discussion of indentation if the OP doesn't bother formatting their code when posting. Instead I look for the obvious and move on.

With so many eyes on the ground, eventually the OP gets a collective view of their problem and its solution.