8/11


#1

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
else:
print 'empty'
it displays error in line 6 can i know my error??


#2

First what is the error ?
second after you copy and paste the code here. highlight it and press CTRL + k and it will indent it as it was
on your screen.

Indentation is important in python.


#3

it was an indentation error i got!


#4

pyg = 'ay'

original = raw_input('Enter a word:')

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

This is the correct script. Notice that lines "print original", "word.." and ""first =word" are tabbed. According to my mentor it is very important in Python.

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

"if" line and "print,word,first" lines must be displaced.

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

I hope you understand what i mean. This discussion forum autocorrects all the tabs.


#5

I was facing the same problem, error on line 6 ( Did you create a variable "word"?).
The "TAB" before the variable worked!!!
Thank you so much!!!!


#6

pyg = 'ay'

original = raw_input('Enter a word:')

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