Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+4 votes

When I ran a for loop it causes the input of all of the numbers to go down in a straight line instead of across on one line. What is the best way to get all of the outputs to stay on one line?

asked in CSC201 Spring 2021 by (8 points)

5 Answers

+6 votes
Best answer

you could try using end="" in your print statement to smush things together in one line

answered by (8 points)
selected by
+2 votes

I did it using an accumulator variable, except instead of accumulating actual numbers, concatenate them like a string. So variable = "" and then concatenate each number to variable until you have the full list.

answered by (4.2k points)
+2 votes

You can create an empty string then add each number into that string (do this inside the for loop)

answered by (8 points)
+2 votes

In the print function, add the end = " ", which will do it for you. Don't forget to add the space in the quotations since the numbers have space.

answered by (4.8k points)
+2 votes

Use end="" in your print function, at the the end

answered by (8 points)