Linked Questions
21 questions linked to/from How can I print variable and string on same line in Python?
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 ...
6 votes
6 answers
9k views
Why is there an extra space in between a variable and punctuation in a string? Python [duplicate]
There is an extra space in the output of a string. This is the section of the code where it happens. It happens in the string of the function, nameConfirmation(). def chooseName(): name = "" ...
0 votes
4 answers
29k views
How to add comma in print statement in Python [duplicate]
I'm new to python and learning how to code. I'm printing last element of my list and sum of the list as- print list[-1],sum But the output is separated by " " and not separated by ",". Any idea how ...
1 vote
6 answers
9k views
How can I print a variable with text in Python? [duplicate]
I am trying to print a text with the name too. from faker import Faker fake = Faker() name = fake.name() print(name) but i want it to print some plain text as well in that print. like Hello, my name ...
0 votes
2 answers
13k views
How do I put a users input into print in Python [duplicate]
I'm very new to python and I am making a text based game. In the start I ask the users name. How would I add what the user input to when I "print"? print ("Welcome to my first game! It's not much but ...
-5 votes
5 answers
2k views
How can I print commas between strings? [duplicate]
say str(q)=hello str(w)=332 str(e)=nasa str(r)=21 What should I do in order to print <hello,332,nasa,21>? Note that brackets and commas are required
0 votes
3 answers
188 views
Print more than one value [duplicate]
C++ std::cout << "Hello world!"; // output: Hello world! Python print("Hello world!") # output: Hello world! That works. But how can I do this in Python? std::string name = "Robert"; std::...
0 votes
2 answers
751 views
Create function to see which students failed the course [duplicate]
I started learning Python and playing around with functions. students = ["Peter", "Mary", "George", "Emma"] student_ages = [24, 25, 22, 20] student_gpa = [3.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 = ...
-4 votes
1 answer
112 views
New to Python, trying to do print statements. College textbook is super short not being helpful [duplicate]
Ok so I'm working on a problem in my python class. I've gotten most of it figured out aside from print statements. I assigned the arguements correctly (I think) and am just trying to get the text to ...
0 votes
0 answers
81 views
How to create place holder in variable for inserting a value while execution [duplicate]
Objective I have a string variable: use_this_string = "If you want to <something here>, then first learn it" and I want to insert a user input value into it like (in REPL mode): >&...
0 votes
1 answer
77 views
printing a float value just besides of a range of floating values [duplicate]
Experts, i want to print a range of values with steps 1.5, and after that i want another float value (10.0) to be print just beside the result of first function .In order to do that i tried the below ...
-1 votes
1 answer
62 views
I want to print variable in string which is writen by user [duplicate]
name = input('enter the name of the coustomer : ',), days = int(input('enter the number of days for :')) I want to print name after the text enter the number of days for (name) (type by user )
-2 votes
1 answer
50 views
Possibility to have no spaces when creating a string? [duplicate]
For example, if I do this: for i in '12345': print("Welcome",i,"times") It outputs: Welcome 1 times Welcome 2 times Welcome 3 times Welcome 4 times Welcome 5 times But I want it like this: ...
-1 votes
1 answer
61 views
"unsupported operand types for +" when trying to print string together with number [duplicate]
I wanted to implement the formula for calculating speed into Python: def speed(): distance = input("What is the total distance? ") time = input("What is the total time taken to ...