10.Ending Up


#14

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
new_word = new_word[1:len(new_word)]
print new_word

else:
print 'empty'
print original

Here you are wizmarco
It says there is a Syntax error with 'else:' I don't know what is wrong. @wizmarco


#15

Hi you should indent the print "original" inside the else statement like the print "empty".


#16

since u r really gd in this i just want to show u my code n cn u just tell me whts wrong with it plz


#17

Hi you shoudl indent your code inside the if statement should be like that

if len(original) > 0 and original.isalpha():
    print original
    word = original.lower()
    .....
    ......

#18

i did but it still dsnt work sorry


cn u just check if its right coz i m a stupid


#19

try to post your code

here how to format your code


#20

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
newword = word+ first+pyg
newword = newword[1:len(newword)]
print new_word
else:
print 'empty'
is this ok?? idk :slight_smile:


#21

when i said you to indent your code it should be like that.

pyg = 'ay'

original = raw_input('Enter a word:')

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

#22

oh ok sorry i m a stupid :frowning:


#23

thnk u for today tho
:slight_smile:


#24

I have no idea what has gone wrong here. Not liking the colon for some reason.
Would appreciate any insight on this?


#25

nm silly me I figured it out.


#26

on line 10, what is the purpose of putting "new_word" again before "[1:len(new_word)]"? just asking because that part confused me.


#27

You're telling it where to cut the new word.


#28

baxter90 What did you figure out? I'm getting the same error.


#29

On line 9 I had not actually applied the slicing to the new_word. Worked fine afterwards.


#30

Thank you, that worked. I'm still curious as to why [1:len(new_word)] doesn't work as it does in the instructions.I must be missing something.


#31

Hello! I have a question.
I don`t know the reason about difference you and me.

at first, why you use word instead of original in line 7. you: first = word[0] me: first = original [0]

secondly, why you delete new_word[0:len(original)].
I just follow instructions, but there is no instructions about deleting new_word[0:len(original)].

I really want to know about it, because I am in stuck.


#32

I assigned a new variable "word" because on line 4, I made sure that "original" was letters only and on line 5, i put it in all lowercase letter. If you want to use original, it may not pass if the user puts in random letters and numbers. As for deleting new_word[0:len(original)], when I looked over the code, it doesn't do anything just sitting there. It's not performing a function or assigning anything, so it gets deleted. Hope that helps


#33

it really helped me! Thanks a lot :slight_smile: