Here's my code:
pyg = 'ay'
original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
if len(original) > 0 and original.isalpha():
if first in 'aeiou':
print 'vowel'
else:
print "consonant"
else:
print "empty"
and here's the confusing error message:
File "python", line 10 print 'vowel(' ^) IndentationError: unindent does not match any outer indentation level
It says this (") is the problem. I can't really continue my learning of Python without my step.
pyg = 'ay'
original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
if len(original) > 0 and original.isalpha():
if first in 'aeiou':
print 'vowel'
else:
print "consonant"
else:
print "empty"
Indentation (the number of spaces from the left before each line of code) is important in Python. Each if
and else
must have the same indentation.
For instance...
if 1 == 1:
else:
...will not work, because there's 0 spaces before if
and there's 4 spaces before else
. So each else
that belongs to a if
statement must be aligned.