ordinal suffix of the letter of a word python 3.5.
<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]
SelectedWords = ['TRAILER', 'LAPTOP', 'SUNFLOWER', 'SKIPPING', 'AIRPLANE', 'HOUR', 'POTATO', 'HUGE', 'TINY', 'GOOD', 'BAD', 'YES', 'NO', 'WAGON', 'QUESTION', 'LAGOON', 'CAT', 'DUCK', 'GOANNA', 'POSTER', 'FUTURE', 'PRINCESS', 'RHYTHM', 'SUDDENLY', 'SNOW', 'MAGNET', 'TOWEL', 'RUNNING', 'SPEAKER', 'QUICKLY']
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 SelectedWords}
</code></pre>

<p>the below is part of a loop that creates random questions from 4 choices and then assigns a word to those questions. </p>

<p>For this question when the program might get a results of what is the letter 5 of hospital, the user would then input a answer and then get a correct or incorrect response. What I'm trying to do is  get the ordinal suffix of  the letter as well . So the question could be "what is the 5th letter of hospital"</p>

<pre><code>        n = random.randint(1, len(x))
        correct = x[n-1]
        if sys.version.startswith('3'):
            ans = str(input('What is letter {} of "{}"?'.format(n, x)))
        else:
            ans = str(raw_input('What is letter {} of "{}"?'.format(n, x)))
</code></pre>

<p>Here is the full revised code. There will obviously be issues with numbers larger than 10, it would be possible to either add numbers to the map or write a function with rules to determine what the correct ordinal suffix would be based on the current map but I know that the original OP didn't want any more than one function. Either way this should help.</p>

<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]
SelectedWords = ['TRAILER', 'LAPTOP', 'SUNFLOWER', 'SKIPPING', 'AIRPLANE', 'HOUR', 'POTATO', 'HUGE', 'TINY', 'GOOD', 'BAD', 'YES', 'NO', 'WAGON', 'QUESTION', 'LAGOON', 'CAT', 'DUCK', 'GOANNA', 'POSTER', 'FUTURE', 'PRINCESS', 'RHYTHM', 'SUDDENLY', 'SNOW', 'MAGNET', 'TOWEL', 'RUNNING', 'SPEAKER', 'QUICKLY']
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 SelectedWords}
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(SelectedWords):
        number_questions = len(SelectedWords)
    sample_questions = random.sample(SelectedWords, number_questions)
    print sample_questions
    print(' Test 1 START')
    print ('---------------------')
    for x in sample_questions:
        print ("Question {}/{}:".format(current_question+1,     number_questions))
        print ('---------------------')
        current_question += 1
        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 = word_map[x]['vowels']
            ans = input('How many vowels does "{}" contain?'.format(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(9)
</code></pre>

python python-3.x