Linked Questions

377 votes
22 answers
751k views

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: ...
Pol's user avatar
  • 25.7k
71 votes
5 answers
126k views

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,...
Ci3's user avatar
  • 4,872
1 vote
3 answers
24k views

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!
Alex Carr's user avatar
3 votes
3 answers
12k views

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 ...
Kit Yeung's user avatar
  • 135
6 votes
3 answers
8k views

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) ...
user avatar
-5 votes
4 answers
4k views

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,...
PyProg's user avatar
  • 75
-2 votes
1 answer
5k views

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)
Gianni Spear's user avatar
  • 8,058
1 vote
2 answers
8k views

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 ...
DoeNd's user avatar
  • 13
1 vote
1 answer
896 views

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 ...
Sapnesh Naik's user avatar
  • 11.7k
1 vote
5 answers
537 views

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,...
Dami Devil's user avatar
2 votes
4 answers
459 views

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 ...
dumpling_san's user avatar
0 votes
2 answers
199 views

For example: list = [1,2,3,4] how would I get this to print something like this: 1 2 3 4
Big boy's user avatar
  • 19
-1 votes
1 answer
471 views

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 ...
Yusuf Ustaoğlu's user avatar
-2 votes
1 answer
285 views

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
Sushmitha Kumaravel's user avatar
0 votes
2 answers
213 views

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 = ...
Melodyyyyy's user avatar
0 votes
2 answers
103 views

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 ...
A programmer 's user avatar
0 votes
3 answers
51 views

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: ") ...
Saurabh G's user avatar
0 votes
1 answer
57 views

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) ...
VirusGOATS's user avatar
0 votes
0 answers
91 views

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 ...
Nikola Mitrovic's user avatar
-1 votes
2 answers
66 views

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 ...
G.Bow's user avatar
  • 1
-2 votes
1 answer
74 views

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....
AZAN SHAHID's user avatar
1 vote
1 answer
58 views

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
hcign's user avatar
  • 43
-1 votes
1 answer
42 views

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 ...
Shardul Malkhare's user avatar
0 votes
0 answers
25 views

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': ...
Noah 's user avatar
695 votes
16 answers
434k views

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 ...
Eli Bendersky's user avatar
394 votes
14 answers
1.3m views

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 ...
user1985351's user avatar
  • 4,719
244 votes
15 answers
316k views

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 ...
Bart's user avatar
  • 11k
189 votes
21 answers
299k views

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 ...
ccwhite1's user avatar
  • 3,805
10 votes
5 answers
37k views

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):...
Hououin Kyouma's user avatar
6 votes
2 answers
6k views

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 ...
Christopher's user avatar
  • 44.7k

15 30 50 per page