using a while True loop
<p><strong>Problem 1.</strong></p>

<p>This problem provides practice using a <code>while True</code> loop. Write a function named
<code>twoWords</code> that gets and returns two words from a user. The first word is of a
specified length, and the second word begins with a specified letter.</p>

<p>The function <code>twoWords</code> takes two parameters:</p>

<ol>
<li>an integer, <code>length</code>, that is the length of the first word and</li>
<li>a character, <code>firstLetter</code>, that is the first letter of the second word.</li>
</ol>

<p>The second word may begin with either an upper or lower case instance of
<code>firstLetter</code>. The function <code>twoWords</code> should return the two words in a list. Use
a <code>while True</code> loop and a <code>break</code> statement in the implementation of <code>twoWords</code>. The
following is an example of the execution of <code>twoWords</code>:
<code>print(twoWords(4, 'B'))</code>:</p>

<pre><code>A 4-letter word please two
A 4-letter word please one
A 4-letter word please four
A word beginning with B please apple
A word beginning with B please pear
A word beginning with B please banana
['four', 'banana']
</code></pre>

<hr>

<p>This is what I have so far, but it keeps asking me the first question over again
even if I have the right word length. What am I doing wrong?</p>

<pre><code>def twoWords(length, firstLetter):
    wordLen = input('A 4-letter word please ')
    while len(wordLen) != int(length):
        wordlen = input('A 4-letter word please ')
    word = input('A word beginning with ' + firstLetter + ' please ')
    while word[0] != firstLetter:
        word = input('A word beginning with ' + firstLetter + ' please ')
    return[wordLen, word]
</code></pre>

<pre><code>def twoWords(length,firstLetter):

    firstWord = "" 
    secondWord= ""

    while True:

        firstWord = input('A ' + str(length) + '-letter word please.')
        if length == len(firstWord):
            break
    while True:
        secondWord = input('A word beginning with ' + firstLetter+ ' please')
        if secondWord[0] == firstLetter.upper() or secondWord[0] == firstLetter.lower():
            break
    return [firstWord,secondWord]

print(twoWords(4,'B'))
</code></pre>

python while-loop