How do I format text inside of a label?

Godot Version

Godot_v4.7.1-stable_win64

Question

I am brand new to coding so please have mercy

I have a list of variables I want to print out but when typed out like this

$Control/Basic_character.text = str(rounded_pun, rounded_dex,rounded_con ... ,rounded_cha)

it’s an incomprehensible line which is to be expected

How do I format each of the variables inside of the .text like putting them on their own line or adding text next to the variable.

ive been trying different things like

$Control/Basic_character.text =  str("strength" rounded_pun, "dexterity" rounded_dex...)

"and"

$Control/Basic_character.text = "strength" str(rounded_pun) 
$Control/Basic_character.text = "dexterity" str(rounded_dex)

"and"

$Control/Basic_character.text = "strength" str(rounded_pun), "dexterity" str(rounded_dex)...

It keeps showing up errors which is to be expected

I just want to be able to see the numbers in a list and put text next to them with each number to say what it represents. Then I can continue programming the level up system, like showing how much each stat goes up by and experience but I can’t without knowing the syntax to format the numbers inside of the text without making 10 different labels. I’m trying to minimise the number of nodes I’m making initially so if that’s just the case then that’s fine but I don’t know if it’s a syntax error or trying to do this in one node.

Thanks for reading.

I recommend reading about formatting strings in the docs.

You also might be better off using a RichTextLabel instead of a simple Label

I know you said you didn’t want to use a different label for each stat, but that is also a valid and good solution.

An example of what should work (I’d still recommend reading more in the docs even if this does what you want)

$Control/Basic_character.text = "strength %d\ndexterity %d"  % [rounded_pun, rounded_dex]

Thank you so much :stuck_out_tongue: that works perfectly and I’ll ready the documentation to see what each one of the things means.

1000 blessings and a good day to you.