Here are a couple of other points to make for a newbie Pythoner:
1) What is the point of writing this?
def isVowel():
if boolean-expression:
return True
else:
return False
You already have the True/False-ness captured in the value of the boolean expression, just:
def isVowel():
return boolean-expression
2) Function calls are performance killers. Especially when you have such a limited set of items to check for, instead of calling .lower() so that you can check against "aeiou", check the character itself against both the lower and upper case letters, "aeiouAEIOU". Even though this is twice the length string to test for membership, it saves us the call to the lower() function.
Here are some performance test results:
import time
import string
time.clock()
reps = 100000
testString = (string.uppercase + string.lowercase) * reps
start = time.clock()
for c in testString:
answer = c.lower() in "aeiou"
end = time.clock()
print end-start
start = time.clock()
for c in testString:
answer = c in "aeiouAEIOU"
end = time.clock()
print end-start
start = time.clock()
for c in testString:
pass
end = time.clock()
Prints:
3.27782246068
1.76839123408
0.713913919227
The third loop shows the time it takes just to iterate over the testString itself, so the time spent in the body of the loop (assuming pass takes negligible time) is:
2.563908541
1.054477315
By avoiding the lower() call, the second technique is more than twice as fast.