8. Word Up



Did you create a variable called word?

pyg = 'ay'

original = raw_input('Enter a word:')

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



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


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


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


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


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?


@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.


Thanks for the help! @rcodeman


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