Print string on specific character position

danrib07
Wed, 16 Oct 2024 23:16:21 +0000
General Usage

Hi everyone, I’m trying to format some diagnostics for a Julia project I’m working on, and I was wondering if there’s a way to format strings such that the output is printed on a specific character position? For example, let’s say I have the following:

person = ["Adam" "Jennifer" "David"]
age = [25 34 57]

for i in zip(person, age)
    println(i[1] * "------" * string(i[2]))
end

which prints the following output:

Adam------25
Jennifer------34
David------57

My question is: is there a method to print ------ and i[2] on specific character positions? For example, if we say the beginning of each line is position zero, how would I go about printing the ------ starting on character position 12 and i[2] on character position 24?

5 posts - 4 participants