Pyglatin


#1

pyg = ‘ay’

original = raw_input(‘Enter a word:’)

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

The error shows
File “python”, line 10
else:
^
IndentationError: unexpected indent

I’m confused here please help


#2

The error type is an indentation error, as you see.

So, your indentation is totally wrong. In Python, the code doesn’t work as you want if you don’t have your indentation fixed. Your code should look like this:


pyg = ‘ay’

original = raw_input(‘Enter a word:’)

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

because the if/else statement is covering the code.
If you have learned HTML or something, you’ll have learned that this is inheritance, with parents and childs.
Here, ‘if’ is parent to everything beneath until ‘else’, which is parent to ‘print ‘empty’’


#4

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