Python Forum
How to force print statement to print on one line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to force print statement to print on one line
#1
I have a print statement (inside a larger program and loop)
print("at", independent_variable, '=', x_interpolation_number[0], dependent_variable, '=', t_interpolation_number[0])
and for some reason the ide is outputting this on three different lines, so the output in the console is
at x
=1 position
=5
is there a way to force the output to simply be
at x=1 position=5
I'm not going to post the entire program here for reasons, but I can't think of anything that would cause this?
I also tried
print("at", independent, '\r=', interpolation_x_values[0], '\r', dependent, '=', interpolation_y_values[0])
but that didn't help
Reply
#2
What is the value of the named variables? Are they contain a newline character?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
If they do contain newline characters ('\n'), you can get rid of them with the strip method of strings (independent_variable.strip()).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
Oh wow, I gave the variables a \n in the other file...
I have no idea how you figured that out with the information I gave you wow.
Reply
#5
(Oct-28-2018, 08:24 PM)wlsa Wrote: I have no idea how you figured that out with the information I gave you wow.
You will. Just practice.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to print directory files (& timestamps) chatguy 3 1,349 Dec-29-2022, 07:19 AM
Last Post: ndc85430
  python code tp determin a userName and print message jackAmin 4 1,789 Nov-20-2022, 12:03 AM
Last Post: rob101
  Print not appearing in output dgizzly 1 1,198 Oct-14-2022, 09:55 PM
Last Post: rob101
  How to print out the children index of the search tree? longmen 7 2,131 Apr-02-2022, 06:58 AM
Last Post: Yoriz
  name.split() + (And) + print question sklord 12 3,633 Mar-26-2022, 05:45 PM
Last Post: deanhystad
  print on a single line with start/end brackets and commas Paulman 2 1,832 Oct-23-2021, 10:00 AM
Last Post: Paulman
  When using print what does end="" do ? yngxng 3 2,043 Oct-18-2021, 12:31 AM
Last Post: jefsummers
Question Recursion and permutations: print all permutations filling a list of length N SantiagoPB 6 3,251 Apr-09-2021, 12:36 PM
Last Post: GOTO10
  Problem with print formatting using definitions Tberr86 2 1,983 Mar-20-2021, 06:23 PM
Last Post: DPaul
Sad I can't print what I need and I can't figure it out **wall** icedragon978 2 2,081 Mar-06-2021, 02:37 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020