1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
7nadin3 [17]
3 years ago
12

What is wrong with this code and correct it.

Computers and Technology
1 answer:
balandron [24]3 years ago
8 0

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:

<em>def swapping_stars(): </em>

<em>    line_str = "" </em>

<em>    for line in range(0, 6): </em>

<em>        for char in range(0,6): </em>

<em>            if line % 2 == char%2: </em>

<em>                line_str += "*" </em>

<em>            else: </em>

<em>                line_str += "-" </em>

<em>        print(line_str) </em>

<em>        line_str = ""</em>

You might be interested in
The Warn-on-Forecast has been developed by the National Weather Service to help predict hazardous weather earlier. Which of the
allsm [11]

Answer:

Federal agencies will be able to disseminate information to large local communitie

Explanation:

the headquarter of National weather service is responsible for to coordinate weather related warnings to organisations to ensure compatibility and effectiveness of weather services and provide  public protection and safety.

National Weather service entered in the new erra of innovation with use of technology they will be able to disseminate information to large local communitie

5 0
3 years ago
Read 2 more answers
What is the output of the following code segment?
Aliun [14]

Answer:

o

Explanation:

8 0
3 years ago
[5]Suppose a 1,600 kg car is traveling at 20.0 m/s. What average force is needed to stop the car in 4.0 s?
SVEN [57.7K]
This is in the wrong caterigore and yes the answer is 8.0 × 103 N 
5 0
3 years ago
Read 2 more answers
There are three types of operators in BASIC-256 <br>a) True b) False​
Anestetic [448]

Answer:

a)True is the answer......

6 0
3 years ago
What is the main function of a file extension?
patriot [66]

To indicate which program is needed to open it

8 0
3 years ago
Other questions:
  • in c Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the li
    14·1 answer
  • When paying bills online, a payee is:
    9·1 answer
  • Lisa is modifying a spreadsheet. Which view will allow Lisa to see how her changes will look when she prints the spreadsheet?
    13·2 answers
  • In the code snippet, what is the “win” part called in programming?
    12·1 answer
  • Which of the following “invisible” marks represents an inserted tab?
    11·2 answers
  • What is wrong with this code and correct it.
    12·1 answer
  • Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
    14·1 answer
  • The stub: transmits the message to the server where the server side stub receives the message and invokes procedure on the serve
    8·1 answer
  • Which item can be added to Outlook messages, like a Word document or PowerPoint presentation, that takes standard bulleted lists
    11·1 answer
  • Question 4 of 25
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!