Respuesta :

Answer:

What's wrong?

The line_str variable needs to be re-initialized at the end of each printing

The correction

Include the following line immediately after the print statement

       line_str = ""

Explanation:

Required

Correct the code

The conditions are correct. However, the string variable line_str needs to be set to an empty string at the end of every of the iteration loop.

This will allow the code to generate a new string.

So, the complete function is:

def swapping_stars():

   line_str = ""

   for line in range(0, 6):

       for char in range(0,6):

           if line % 2 == char%2:

               line_str += "*"

           else:

               line_str += "-"

       print(line_str)

       line_str = ""