-1

I have a Python script that prints some numbers, like this:

results = [42, 21, 64, 32, 16, 8, 4, 2]
for number in results:
    print(number, end=' ')

In the console, the output of this script is:

42 21 64 32 16 8 4 2 ⏎ 

Why is there a weird character at the end?

My IDE is LunarVim. My shell is Fish.

wovano
  • 4,543
  • 5
  • 22
  • 49
Rahil Prakash
  • 11
  • 1
  • 5
  • Your IDE/shell is just highlighting an otherwise "invisible" return character…!? – deceze Nov 22 '22 at 11:26
  • 1
    See [fish shell outputs ⏎ (i.e. an "abandon line") during startup on smaller terminal sizes](https://superuser.com/questions/1641529/fish-shell-outputs-i-e-an-abandon-line-during-startup-on-smaller-terminal) on Super User – wovano Nov 22 '22 at 11:31
  • 1
    Thanks! So it indicates that there's no trailing newline? – Rahil Prakash Nov 22 '22 at 11:35
  • 2
    Yes, that's what it means. So simply adding `print()` at the end of your script should solve it. – wovano Nov 22 '22 at 11:39

1 Answers1

0

Fish shell outputs ⏎

This is essentially fish's way of telling you that there is no trailing newline or "\n". Using print() will probably not result in this. In bash, the terminal may start after the output, instead of the next line.

Rahil Prakash
  • 11
  • 1
  • 5