4

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)

2 Answers2

4

You can also write to stdout directly with

stdout.write "number: "
echo i

which will print a newline after printing the value of i

ynfle
  • 171
  • 1
  • 3
2

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

echo "number: " & $i
Jason
  • 531
  • 6
  • 19