Search code examples
nim-lang

How to print without skipping a line in Nim


I would like to print without skipping lines in Nim.

this is my code by far

int i = 1
for i in countup(1, 10):
  echo "number: "
  echo i

I would like the output to be:

number: (i value)
...

instead of:

number:
(i value)

Solution

  • Convert i to a string with the $ operator, then concatenate the strings using the & operator.

    echo "number: " & $i