8. Word Up


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/1/2?curriculum_id=4f89dab3d788890003000096#


Did you create a variable called word?


pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
else:
    print 'empty'
word


#2

Instruction:

Inside your if statement:

Create a new variable called word that holds the .lower()-case conversion of original.

so the variable word should be inside if.

if len(original) > 0 and original.isalpha():
    #code should be here
    print original

#3

could you put the correction of the code ? I don't have any idea of the code lines that i should write...
Thanks!


#4

Don't worry i'll surely help you :slight_smile:

can you tell me exactly what you don't know? did you completely understand the instruction?

have a look at the example in the lesson


#5

Would you mind explaining why the "word" variable and the "first" variable need to be inside the if statement?


#6

I got a but hung-up here as well. The code is pasted here, but do not look further if you don't want any spoilers! To be honest, I figured it out but it still doesn't make sense to me. Does anyone know why this bit of code falls under the "if" statement?


#7

@dempancakes and @boardjumper63595
It is because suppose user enters 12345 and your word and first variable is outside if
then in spite of non-alphabetical characters it'll try to make the numbers to lowercase
that doesn't make sense and for first variable it'll take the element of first index that is
non-alphabetical characters what we don't want that's why we put the codition in if.
Also if users enters nothing and then press enter yet it'll read all the lines of code that is waste of time too.


#8

Thanks for the help! @rcodeman


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.