Today I’m going to explain the last two smaller functions I created. These two functions are meant to verify that there is a vowel in the first three letters submitted, and once verified will return True. First I started by creating a function only meant to check for vowels. Here is my function.
vowel = 'aeiou'
for v in vowel:
if v in word:
if len(word) == 3:
foundvowel = vowel(word)
if foundvowel == False:
I separated the two functions because it made it easier for me to view and understand my code. I could most certainly have combined them, and might do so in the future, but as this was my first attempt at creating a more complicated piece of code on my own I decided to simplify it as much as possible. Doing so helped me a lot in later debugging.
Notes on Debugging: The preghost() function was originally written differently. When I first wrote it I hadn’t put in my return statements in the correct spots. I had only placed them in once or twice and because of that my final processing function (ghost()), wasn’t actually running the function. As my vowel() function is only called within the preghost() function, that meant I wasn’t calling either function. When I started debugging I had no idea my bug lay in my poorly inputted return statements, that is, I didn’t have any idea until I had Robey review if for me. It was a learning experience to know that my return statements from the preghost() function, placed incorrectly, was bypassing a good chunk of my code.
Up Next Time: The final processing function to ghost()