Python Loop To Print Asterisks Based on User Input
<p>I'm trying to create a python program to print a certain number of asterisks based on user input. My code is below</p>

<pre><code>num_stars = 3
num_printed = 0

while num_printed &lt;= num_stars:
    print('*')
</code></pre>

<p>The output is an infinite loop. I want to print the number of stars variable as asterisks.</p>

<p>You need to increment the num_printed variable.</p>

<pre><code>num_stars = 3
num_printed = 0

while num_printed &lt; num_stars:
    print('*')
    num_printed += 1
</code></pre>

<p>Also note that I changed the <code>&lt;=</code> to <code>&lt;</code>: you want to be checking for when <code>num_printed</code> is no longer less than the total number of stars, which will happen after the last start is counted, and your counter increments.</p>

python