Ending Up


#1



Kindly help
which part did i miss ?
thank you :slight_smile:
below is my code and error :


pyg = 'ay'

original = raw_input('Enter a word:')

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

the error message after i execute it is:
Oops, try again. It looks like you printed the correct translation of "ok", but make sure to set new_word equal to the slice as well..


#2

your code is fine, but for validation purpose you need to store the slice of word in new_word, you could just do that on this line:

new_word = word + first + pyg

just take the slice of word (1:len(word)), and then on the next line print new_word:

print new_word

#3

Don't you have to print new_word[1:len(new_word)] not just new_word at the end? Also, I thought it was necessary to make new_word equal to new_word[1:len(new_word)].


#4

If we read the instructions, the above follows what is asked for. Likewise, the instructions ask for,

new_word = new_word[1:len(new_word)]

Variations are accepted by the SCT, but we should ourselves stick to the instructions when answering questions.


#5

thank you! this really works,
now i get it what i miss,
thank you all for those who are helping me.


#6

true, but i hadn't closely looked at the instructions, what you for example also could do is:

new_word = word[1:len(word)] + first + pyg
print new_word

this was given the code afif_7 had created a good way to solve the problem, sometimes you can solve a problem multiply ways


#7

the code i wrote in the program was like this

new_word = word + first + pyg
new_word = new_word[1:len(new_word)]

thank you for giving me the other options as u teach above:

new_word = word[1:len(word)] + first + pyg
print new_word

#8

sometimes there are multiply ways to solve a problem :slight_smile:


#9

thank you!.

how do i close this topic ?
since it already solved.


#10

#11

you can't close it, most topic should auto class once you select an answer which you mark as solved.

I closed it manually now