What´s wrong with my code?!


#1

I am new to coding, so I´m not quite sure where I´m wrong... The error message says my syntax is incorrect, but I just can´t simply find the error. Can someone please help me?


Here it is my code...

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

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


#2

Here is your problem. new_word not only has to equal [1: len(new_word)] but also something else with [1: len(new_word)]. For example

new_word = something[1: len(new_word)]

Also, just suggesting this not necessary, but I would have a print original in your code in your if statement just so you can see the original word and the new word printed on the computer screen.


#3

oowww now I see! Thank you so much!


#4

Good! Glad to have enlightened you on the subject! :smiley: Happy coding!


#5

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