10. Ending Up


#1

I'm getting this error message can anyone help me please.


#2

Move the print up a line and don't print original.


#3

hi.. Can u show me in code what do you mean.


#4

i wrote this code :slight_smile:
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'

It Shows the output as
Enter a word: cool
oolcay

seems to be working but this is not what the instructions say.


#5

Go back a couple of lessons and work forward again. It should straighten itself out. Do exactly what the instructions ask. (Granted they don't say to not print original but that is a problem that goes away when we don't.)

Granted, you were on the right course, but not according to instructions. After passing with the instructed code, refactor it to what you had originally and try again.


#6

I did it before hand, have been following instructions right from the start, this code have been running since few lessons back and i have doubled checked on it. With the new code that i posted it works fine but not with the one they had in instructions.


#7

Your original code (in the image) is right all the way up to line 9, then falls off the rails.

Add a print to line 9 and remove line 10 and you have a finished statement.


#8

Here i wrote the code u said,
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 original
else:
print 'empty'

still gives the same error as the picture.


#9

this is the line where you want to print your slice, not the original. I don't get that you are not getting this.


#10

did what you said and got a new error.


#11

I got the same error, I managed to fix it by having 'new_word = new_word[1:]' on line 10 (below the print line)


#12

Which is fine if it was in the instructions, but it is not. The author asks for

[1:len(new_word)]

just to be sure we understand the concept slicing indices. Glad to see you have the right idea, though.


#13

Yup i too fixed by using this code:
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'

but it's not mentioned in the instructions that's the only problem..


#14

It's not a problem, but an anomaly. The lesson checker is obviously not checking code, proper, but what results. That's cool in the sense that it permits refactoring of our code once we have followed the instructions. It's not cool when we evade them. Refactoring happens after we have a working model, not before.

In truth, this lesson checker will let anything by that acutally does the job.

    print "{}{}{}".format(word, word[0], pyg)[1:])

#16

Shouldn't something like this be monitored or like there should be something that ppl can tell them to look into


#17

It has been monitored for years. Minor concerns that do not block progress are a low priority. The key is that the lesson accepts the right answer, whether got by following instructions or by refactoring our code. I don't see this as an issue.


#18

Yup you are right.. thank you for your assistance..


#19

I got stuck on this as well, thanks for the help!


#20