Hello
So, this is my first line of code and in the challenge we had to create our own string that gradually increases with the spacebar being hit.
I created a variable called count_up and declared it as int
and set the value as 0
var count_up: int = 0
I found a way to concatenate the string so that it reads “Spacebar was pressed x times” on one line, rather than two, like so.
To do this I updated the print statement to include + str(count_up)
(converting the int
to a string
)
if Input.is_action_just_pressed("ui_accept"):
print("Spacebar was pressed " + str(count_up) + " times")
count_up = count_up + 1```
and it displayed nicely in the console.
I hope this helps anyone trying to figure out how to add their message as one long string.