Lesson 8 Word Up question


#1

Hi all, my codes are as followings:-

to me the instruction is confusing. How do I create a variable INSIDE the if statement? Do i have to put in everything before the : ? or after? Either way, it always ask me if I have created a Word Variable.

What do you have?

Thanks,


#2

You have missed out the colon after the if statement.Correct it and execute the code again

original = raw_input('Enter a word:')

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

#3

Hi samauden, thanks, i got it as below

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word [0]

print first

else:
print 'empty'

when i print it out, it is the lower case first letter of my input


#4

It's my pleasure john


#5

That code works fine, just tried it following the advice given. Makes much more sense now. Thanks., helped me a lot. Au Revoir


#6

the answer to this is:
pyg = 'ay'

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


#7

Oops, try again. It looks like word is set to "the_string.lower()" instead of "f".