How to print statements in one line

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Saphereye

In python you can do
print("Hello", end = '') print("World")
to produce "Hello World" as a string,
Is there a similar functionality for print in GDScript?
If it helps : i am trying to print out a list in a form of table

Edit : I FOUND A WAY, kind of, i used a string to record each iteration and printed it in the end of loop, eg:
if i have numList = [1,2,3,1,2,3,1,2,3]
outputString= '' for x in 3: ....for y in 3: ........outputString += numList[x + 3 * y] ....print(outputString) ....outputString = ''

It might not be elegant, but it does the job

:bust_in_silhouette: Reply From: jgodfrey

I’m not sure where (or why) you’re trying to use the print function, but… There’s a similar printraw('string') function that does not automatically add newline, but it only outputs to the terminal window, not to in-editor console.



Will output

:bust_in_silhouette: Reply From: BigBadWouf


Not sure what you want to achieve but you can do something like this :

print("Hello", " ", "World")

It print “Hello World” in the godot console.
You can print var or whatever you want :

var one_var : String = "Big"
print("Hello ", one_var, " World")

It print “Hello Big World”.

IF not a string, use the str() function :

var one_var : int = 100
print("You have ", str(one_var), " dollars")

It print "You have 100 dollars.

By default, print() try to convert variable as string. So many built-in type don’t need str() like Vector, Dictionnary, Array…
You can use ’ instead " for raw like :

print("Hello", '\n', "World")

It print :

But, i don(t think we can loop on array (for example) inside print function.