Loop character A/B alternately
<p>How can I print A/B character alternately in python loop?</p>

<p>What I expect in result:</p>

<pre><code>oneA
twoB
threeA
fourB
...
</code></pre>

<p>You could also try using the modulus operator % on the index of an incremented for loop for the numbers to alternate the letters:</p>

<pre><code>list_num = ['one', 'two', 'three', 'four', 'five', 'six']
list_alpha = ['A', 'B']
list_combined = []
for i in range(0, len(list_num)):
    list_combined.append(list_num[i] + (list_alpha[1] if i % 2 else list_alpha[0]))
list_combined
&gt;&gt;&gt; ['oneA', 'twoB', 'threeA', 'fourB', 'fiveA', 'sixB']
</code></pre>

python loops for-loop