python 3.5 for loop defined functions placed in the loop
<p>Ok I have been trying to use a input Int function to set how many questions are asked at the start however the input doesn't seem to want to go through. It can be done right?  I all I want is to be be able to alter the  start_test() value. 
While when the user enter a inter correct answer I want the error message to display the correct answer after the Wrong. </p>

<pre><code>import random
import string
import sys
# Used to refer to the what constinutes a vowel
vowels = ['a', 'e', 'i', 'o', 'u']
# Used to refer to the what constinutes consonant
consonants = [x for x in string.ascii_lowercase if x not in vowels]
#List of words used for 
candidateWords = ['HELLO', 'GOODBYE', 'NAME', 'DAY', 'NIGHT', 'HOUR', 'POTATO', 'BIG', 'SMALL', 'GOOD', 'BAD', 'YES', 'NO', 'HOUSE', 'QUESTION', 'BALLOON', 'CAT', 'DUCK', 'PIGEON', 'POSTER', 'TELEVISION', 'SPY', 'RHYTHM', 'SUBSTANTIAL', 'SNOW', 'MAGNET', 'TOWEL', 'WALKING', 'SPEAKER', 'UNCHARACTERISTICALLY']
word_map = {x:{'consonants':len([y for y in x.lower() if y in consonants]), 'vowels':len([y for y in x.lower() if y in vowels]), 'letters':len(x)} for x in candidateWords}
ordinal_map = {1:'st', 2:'nd', 3:'rd', 4:'th', 5:'th', 6:'th', 7:'th', 8:'th', 9:'th', 10:'th'}

def start_test(number_questions):
    current_question = 0
    correct_questions = 0
    if number_questions &gt; len(candidateWords):
        number_questions = len(candidateWords)
    sample_questions = random.sample(candidateWords, number_questions)
    print(' Welcome to Samuel Mays English Test')
    print ('---------------------')
    for x in sample_questions:
        print ("Question {}/{}:".format(current_question+1,     number_questions))
        print ('---------------------')
        #
        current_question += 1
       #q_type or question type uses a random inter between one and 4 elif is then used to set up
       # what occurrs on an instance of each number in the set range
        q_type = random.randint(1, 4)
        if q_type == 1:
            # if one is rolled  the how many letter question is asked
             # it refers to the word map and looks at the letters entry.
            correct = word_map[x]['letters']
         #Input that is presented to the user
            ans = input('How many letters does "{}" contain?'.format(x))
        elif q_type == 2:
        # if two is rolled  the how many vowel question is asked
        # it refers to the word map.
            correct = word_map[x]['vowels']
        #Input that is presented to the user
            ans = input('How many vowels does "{}" contain?'.format(x))
        elif q_type == 3:
        # if three is rolled  the how many vowels question is asked
            correct = word_map[x]['consonants']
            ans = input('How many consonants does "{}" contain?'.format(x))
        else:
            n = random.randint(1, len(x))
            correct = x[n-1]
            if sys.version.startswith('3'):
                ans = str(input('What is the {}{} letter of "{}"?'.format(n, ordinal_map[int(n)], x)))
            else:
                ans = str(raw_input('What is the {}{} letter of "{}"?'.format(n, ordinal_map[int(n)], x)))
        if str(ans).lower() == str(correct).lower():
            print('Well done correct! :)')
            correct_questions += 1
        else:
            print('Wrong')

    print ('You have completed your test!')
    print ("    Score {}/{}:".format(correct_questions , number_questions))
    try_again = input('Would you like to try again? (y/n)').lower()
    if try_again == 'y' or try_again == 'yes':
        start_test(number_questions)

start_test(5)
</code></pre>

<p>tring to figure out how how to the results of a defined function into the loop</p>

<pre><code>def prompt_vowel_count(word):
     correct = word_map[word]['vowels']
     ans = input('How many vowels does "{}" contain?'.format(word))
     return check(int(ans), correct)
</code></pre>

<pre><code>import random
import string
import sys

vowels = ['a', 'e', 'i', 'o', 'u']

consonants = [x for x in string.ascii_lowercase if x not in vowels]

candidateWords = ['HELLO', 'GOODBYE', 'NAME', 'DAY', 'NIGHT', 'HOUR', 'POTATO', 'BIG', 'SMALL', 'GOOD', 'BAD', 'YES', 'NO', 'HOUSE', 'QUESTION', 'BALLOON', 'CAT', 'DUCK', 'PIGEON', 'POSTER', 'TELEVISION', 'SPY', 'RHYTHM', 'SUBSTANTIAL', 'SNOW', 'MAGNET', 'TOWEL', 'WALKING', 'SPEAKER', 'UNCHARACTERISTICALLY']
word_map = {x:{'consonants':len([y for y in x.lower() if y in consonants]), 'vowels':len([y for y in x.lower() if y in vowels]), 'letters':len(x)} for x in candidateWords}
ordinal_map = {1:'st', 2:'nd', 3:'rd', 4:'th', 5:'th', 6:'th', 7:'th', 8:'th', 9:'th', 10:'th'}

def prompt_vowel_count(word):
     correct = word_map[word]['vowels']
     ans = input('How many vowels does "{}" contain?'.format(word))
     return correct, ans

def start_test(number_questions):
    current_question = 0
    correct_questions = 0
    if number_questions &gt; len(candidateWords):
        number_questions = len(candidateWords)
    sample_questions = random.sample(candidateWords, number_questions)
    print(' Welcome to Year One Greens English Test')
    print ('---------------------')
    for x in sample_questions:
        print ("Question {}/{}:".format(current_question+1,     number_questions))
        print ('---------------------')
        current_question += 1
       #q_type or question type uses a random inter between one and 4 elif is then used to set up
        q_type = random.randint(1, 4)
        if q_type == 1:
            correct = word_map[x]['letters']
            ans = input('How many letters does "{}" contain?'.format(x))
        elif q_type == 2:
            correct, ans = prompt_vowel_count(x)
        elif q_type == 3:
            correct = word_map[x]['consonants']
            ans = input('How many consonants does "{}" contain?'.format(x))
        else:
            n = random.randint(1, len(x))
            correct = x[n-1]
            if sys.version.startswith('3'):
                ans = str(input('What is the {}{} letter of "{}"?'.format(n, ordinal_map[int(n)], x)))
            else:
                ans = str(raw_input('What is the {}{} letter of "{}"?'.format(n, ordinal_map[int(n)], x)))
        if str(ans).lower() == str(correct).lower():
            print('Well done correct! :)')
            correct_questions += 1
        else:
            print('Wrong')

    print ('You have completed your test!')
    print ("    Score {}/{}:".format(correct_questions , number_questions))
    try_again = input('Would you like to try again? (y/n)').lower()
    if try_again == 'y' or try_again == 'yes':
        start_test(number_questions)

start_test(5)
</code></pre>

python python-3.x python-3.5