Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.

Here is the answer for the question – Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.. You’ll find the correct answer below

Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.
while num_printed != num_stars:
print(‘*’)
Sample output with input: 3
*
*
*

The Correct Answer is

num_printed = 0while num_printed != num_stars: print(‘*’) num_printed+=1

Reason Explained

num_printed = 0while num_printed != num_stars: print(‘*’) num_printed+=1 is correct for Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.

Leave a Comment