Linked Questions
64 questions linked to/from How can I print multiple things on the same line, one at a time?
377 votes
22 answers
751k views
Print in one line dynamically [duplicate]
I would like to make several statements that give standard output without seeing newlines in between statements. Specifically, suppose I have: for item in range(1,100): print item The result is: ...
71 votes
5 answers
126k views
How can I suppress the newline after a print statement? [duplicate]
I read that to suppress the newline after a print statement you can put a comma after the text. The example here looks like Python 2. How can it be done in Python 3? For example: for item in [1,2,3,...
1 vote
3 answers
24k views
How to print on the same line in Python [duplicate]
Is it possible to print text on the same line in Python? For instance, instead of having 1 2 3 I would have 1 2 3 Thanks in advance!
3 votes
3 answers
12k views
Put function outputs to a list in Python [duplicate]
The aim of the following program is to convert words in 4 characters from "This" to "T***", I have done the hard part getting that list and len working. The problem is the program outputs the answer ...
6 votes
3 answers
8k views
how to wait and print on the same line python [duplicate]
ok, so I am doing this tiny countdown function in vpython, the way I am doing it now is import time print "5" time.sleep(1) print "4" time.sleep(1) print "3" time.sleep(1) print "2" time.sleep(1) ...
-5 votes
4 answers
4k views
Printing on only one line [duplicate]
I have a program that has to only print data onto one line. What can I do to do this. for i in range(10): print(i) Is it possible to print all of this on one line so it prints 0, erases the line,...
-2 votes
1 answer
5k views
Python print a list of two element in one line in a loop [duplicate]
i have a list as: one = [(1, 2), (3, 4)] for o in one: print o (1, 2) (3, 4) i need to print (1, 2) and (3, 4) in the same line for o in one: print o (1, 2) (3, 4)
1 vote
2 answers
8k views
Print two or more outputs from functions side by side in python [duplicate]
I'm a little new to Python and I was wondering how you would present more than one output side by side if it was part of different functions. So for a simple example: def function1(): print("This ...
1 vote
1 answer
896 views
python 2.7 | carriage return not working [duplicate]
I am trying to use \r to print to the same line in bash (Ubuntu 16.04 terminal) but it doesn't work, as the program still prints frame number in a new line. Here is the code i = 0 while img is not ...
1 vote
5 answers
537 views
How can I print the following horizontally, not vertically [duplicate]
im triying to print horizontally Text="Si ya conoces Colab, echa un vistazo a este vídeo para obtener información sobre las tablas interactivas" List= [31,43,15,5,26,32,6,1,3,62,62,62,62,62,...
2 votes
4 answers
459 views
Python: How to print results from conditions all in one line [duplicate]
I'm new to coding, and I found this exercise problem in a Python practice website. The instructions go like this: "Write a function translate() that will translate a text into "rövarspråket" (Swedish ...
0 votes
2 answers
199 views
How would I print a certain part of a list on the same line, and another part of lists on different lines in python? [duplicate]
For example: list = [1,2,3,4] how would I get this to print something like this: 1 2 3 4
-1 votes
1 answer
471 views
How to print multiple patterns next to each other? [duplicate]
My forest pattern I did print the forest pattern here but i have to print them next to each other instead of printing them in new lines. How can i do that? When i try to add end="" to last ...
-2 votes
1 answer
285 views
How to print output in Single line [duplicate]
I want to know how to print output in a single line I want to print it like: 1234 instead of 1 2 3 4 Code: # n = (get in from user) i=1 while (i<=n): print (i,) i +=1
0 votes
2 answers
213 views
Print random integer and phrase in same line? [duplicate]
Not sure if this is asked before but: How do you print "searching for x" where "x" is a random integer? I have my code below: from random import randint numbers = [] random = ...
0 votes
2 answers
103 views
How to print without a newline without using end=" "? [duplicate]
I need to design a function named firstN that, given a positive integer n, displays on the screen the first n integers on the same line, separated by white space. An example of using the function ...
0 votes
3 answers
51 views
I want this python problem's output in a perticular format, but dont know how to format it? [duplicate]
This is my program : def question_second_solution(nums): print("Even Numbers: ") even_nums = list(filter(lambda x: x%2==0,nums)) print(even_nums) print("Odd Numbers: ") ...
0 votes
1 answer
57 views
I'm new to python and I am trying to figure out how to print letters one at a time on the same line [duplicate]
This isn't my actual code but it is just an example. How do I make it my code wait but stay on the same line? import pygame pygame.init() print("Hi") pygame.time.wait(1000) ...
0 votes
0 answers
91 views
Python specific "same line" printing [duplicate]
I'm searching for printing this : random_numbers = [1, 5, 25, 4, 60] print("Numbers are : ") for elem in random_numbers : print(elem, end=' ') and the result have to be like this : Numbers ...
-1 votes
2 answers
66 views
How do I get these numbers to group together? [duplicate]
I currently have for i in range (1,26,1): for e in range (1,7,1): print i**e I am supposed to get the outcome: 1 1 1 1 1 2 4 8 16 32 3 9 27 81 243 … 25 625 15625 390625 9765625 ...
-2 votes
1 answer
74 views
How to update the same line in terminal output (not print new lines)? [duplicate]
I'm trying to write a simple Python script that updates a line in the terminal every second. Here's my current code: import sys from time import sleep def main(): for i in range(11): sys....
1 vote
1 answer
58 views
How to make two python functions run on the same line [duplicate]
print("||") + os.system('PING -n 1 {} | FIND "TTL="'.format(host)) the output is: || reply from {}: ms etc is it possible to make it like this? || reply from {}: ms etc
-1 votes
1 answer
42 views
How does we print the output in column [duplicate]
I have one problem in programming.The problem is that I have to give a input of one number and it will print all numbers from that number Here if i give the input of 3 : Then output will be 123 I ...
0 votes
0 answers
25 views
How can I add these if and elif statements into a single string instead of printing out each statement on its own line? [duplicate]
def main(): phoneNumber = str(input('Please enter your phone number (XXX-XXX-XXXX): ')) for count in phoneNumber: if count == '0': print('0') elif count == '1': ...
695 votes
16 answers
434k views
Disable output buffering
Is output buffering enabled by default in Python's interpreter for sys.stdout? If the answer is positive, what are all the ways to disable it? Suggestions so far: Use the -u command line switch Wrap ...
394 votes
14 answers
1.3m views
How can I print multiple things (fixed text and/or variable values) on the same line, all at once?
I have some code like: score = 100 name = 'Alice' print('Total score for %s is %s', name, score) I want it to print out Total score for Alice is 100, but instead I get Total score for %s is %s Alice ...
244 votes
15 answers
316k views
How do I keep Python print from adding newlines or spaces? [duplicate]
In python, if I say print 'h' I get the letter h and a newline. If I say print 'h', I get the letter h and no newline. If I say print 'h', print 'm', I get the letter h, a space, and the letter ...
189 votes
21 answers
299k views
How to overwrite the previous print to stdout?
If I had the following code: for x in range(10): print(x) I would get the output of 1 2 etc.. What I would like to do is instead of printing a newline, I want to replace the previous value and ...
10 votes
5 answers
37k views
How to print list elements in one line?
I need to print the sorted list of integers, but it should be in a line and without the list square brackets and without any '\n' in the end... import random n = int(input("")) l=[] for i in range(n):...
6 votes
2 answers
6k views
Why do python print statements that contain 'end=' arguments behave differently in while-loops? [duplicate]
I'm running python version 2.7.3 on MacOSX. Consider this block of code: from __future__ import print_function import time x = 0 while x < 5: print(x) x += 1 time.sleep(1) If I run ...