Rachel M.

asked • 03/09/23

I need help getting rid of a line of code without messing up the code*Look at comments ran out of characters*

def run_sim(stops, boarding_rate, exiting_rate, passengers):

  stop_count = 1

  while stop_count <= stops:

    if stop_count == stops:

      boarding = 0

      departing = passengers

    else:

      boarding = boarding_rate

      departing = min(passengers, exiting_rate)

    print(f"{stop_count:^10d}{passengers:^10d}{boarding:^10d}{departing:^10d}")

    stop_count += 1

    if stop_count <= stops:

      passengers = calc_boarded(boarding, departing, passengers)

    print(f"Final Stop: {passengers} on the bus") *Need to get rid of this one*

Rachel M.

Her is the calc_boarded fucntion def calc_boarded(boarding, departing, current):  return current + boarding - min(departing, current) print(calc_boarded(15, 25, 10))
Report

03/09/23

Rachel M.

I only want the output from print(f"{stop_count:^10d}{passengers:^10d}{boarding:^10d}{departing:^10d}") to be shown
Report

03/09/23

Rachel M.

Here si the test statement my professor used to show the output print(run_sim(10, 15, 10, 5))
Report

03/09/23

Daniel B.

tutor
I am not sure about what you need, but could you not simply remove the last line and add the line return "" ? You would have to make sure that it is indented at the same level as your very first statement, not at the same level as the removed print statement.
Report

03/09/23

Rachel M.

I've tried that it doesnt give out the correct output when I do that. whe I have the return indented with the while loop it gives out the correct output, but with none right after the out put
Report

03/09/23

Daniel B.

tutor
What is the correct output?
Report

03/09/23

Rachel M.

The correct out put is a table. It wont let me copy in past it but I'll try and show what it is. (where a number 1 through 10 shows that being of that row in that table followed by three different numbers 1 5 15 5 2 15 15 10 3 20 15 10 4 25 15 10 5 30 15 10 6 35 15 10 7 40 15 10 8 45 15 10 9 50 15 10 10 55 0 55
Report

03/09/23

Daniel B.

tutor
That is the table I got with the program in the answer section.
Report

03/09/23

1 Expert Answer

By:

Rachel M.

While this works. It is not what I want. The return "" just adds an empty line after the output. I can not have anything after the output. It has to be just the plain output.
Report

03/09/23

Daniel B.

tutor
How is my second version?
Report

03/09/23

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.