Word up


so like this?

pyg = 'ay'

original = raw_input('Enter a word:')

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

    print 'invalid'
word = original.lower() 
first = word[0]

I get this error can some one tell me what this error means and what I did wrong

Traceback (most recent call last):
File "python", line 12, in
IndexError: string index out of range

Word Up

Please tell me you did enter something when you where prompted to enter a word....


it doesn't convert to lower case and shows the error when I don't type a word


It does convert to lowercase, but you don't print the lowercase version anywhere.

Well, if you don't enter a word, then word[0] can't get the first letter, since there is no letter at that index, resorting in a indexError


You have to type it under the if not the else, that's why it is showing the error


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