Word up


#1

so like this?

pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
    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
#2

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


#3

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


#4

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


#5

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


#6

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