Ending up?


#1

i can't understand what's wrong?
everything seems to be right, i am breaking my brain to find out why it ain't work

pyg = 'ay'

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

#2

This line needs one level of indentation. Add four spaces in front and you're good.


#3

Well, not really. The above advice is good, for that line. There are issues further above that need to be addressed.

Script reads top down, which means order matters. When we test for certain conditions it is critical to the end result. Order helps to remove assumptions


#4

thanks! your advice was perfect and i passed it. what are the other issues? and also, when do i need to add the spaces?


#5

Consider the test line,

if len(original) > 0 and original.isalpha():

Its purpose is to validate the raw input, not show up late to the party at the output stage. Unwanted guest at this point.


#6

Hint

original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
    the_lot = '''
        all the code that fits the bill
        goes in this allotted space.
    '''
else:
    print "empty"

with the else at the end.


#7

got it :slightly_smiling: and last thing - what are the spaces for? and when should i put spaces?


#8

In preformatted text they have no programmatic value. In Python code, they are block levels. Confuse that at one's own peril.


#10

I'm sorry if this is confusing you. The spaces in some instances have no meaning, such as my pseudo variable, 'the_lot'. Replace this variable and all its contents with a block of code. All the stuff that previously was written above this line that should have followed it.


#11

thank you very much!