Syntax error


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096#


Greetings, my friends. My code shows syntax error. Can I know where is the mistake? Thank you in advance.


 original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
    print original
    pyg="ay"
    word=orignal.lower()
    first=word[0]
    new_word=word+first+pyg
    print new_word
    new_word=[1:len(new_word)]
    print new_word=[1:len(new_word)]
    
else:
    print 'empty'


#2

remove space before original

 original = raw_input('Enter a word:') //IndentationError: unexpected indent

and

word=orignal.lower()  // check spelling here

and

new_word=[1:len(new_word)] //

here you created a variable named new_word to store the value but for slice your code should be look like

new_word=new_word[1:len(new_word)]

or

new_word=new_word[1:]

NOTE:When slicing until the end of the string, instead of providing len(new_word), you can also not supply the second index.

next you just need print new_word not new_word=[1:len(new_word)] beacuse the value already stored.


#3

Thank you Mr. rcodeman. It was very helpful.


#4

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