<p>This is an exercise from &quot;How to think like a Computer Scientist.&quot;<br>
<br>
<br>
The following example shows how to use concatenation and a <span class="code"><span class="keyword">for</span></span> loop to generate an abecedarian series.  &quot;Abecedarian&quot; refers
to a series or list in which the elements appear in alphabetical
order.  For example, in Robert McCloskey's book <i>Make Way for
Ducklings</i>, the names of the ducklings are Jack, Kack, Lack, Mack,
Nack, Ouack, Pack, and Quack.  This loop outputs these names in order:

</p>
<p><span class="code">prefixes = <span class="quote">&quot;JKLMNOPQ&quot;</span>
<br>suffix = <span class="quote">&quot;ack&quot;</span>
<br>
<br><span class="keyword">for</span> letter <span class="keyword">in</span> prefixes:
<br>&nbsp; <span class="keyword">print</span> letter + suffix
<br></span></p>

<p>
The output of this program is:

</p>
<p><span class="code">Jack
<br>Kack
<br>Lack
<br>Mack
<br>Nack
<br>Oack
<br>Pack
<br>Qack
<br></span></p>

<p>
Of course, that's not quite right because &quot;Ouack&quot; and
&quot;Quack&quot; are misspelled.<i><span style="font-style: italic;"><br>
</span></i></p>
<p><i><span style="font-style: italic;"></span>As an exercise, modify the program to fix this error.<br>
</i></p>
<p>==================================================<br>
</p>
<p>In trying to solve the problem I have come up with the following:<br>
</p>
<p>prefixes = 'JKLMNOPQ'<br>
suffix = 'ack'<br>
xsuffix = 'uack'<br>
<br>
<br>
for letter in prefixes:<br>
&nbsp;&nbsp;&nbsp; n = 0<br>
&nbsp;&nbsp;&nbsp; if prefixes[n] == 'O' or 'Q':<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print prefixes[n] + xsuffix<br>
&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print letter + suffix<br>
</p>
<p>--- I know it doesn't work, but want to know if I am on the right track.&nbsp; And what is the solution?<br>
</p>
<p>Thanks<br>
</p>
<p>Ben<br>
<i><span style="font-style: italic;"></span></i></p>
<blockquote>
</blockquote>