Reputation: 31
I am trying to display the values of my eight sensors like this:
print(sensors[1], sensors[2], sensors[3])
print(sensors[4], "P", sensors[5])
print(sensors[6], sensors[7], sensors[8])
(the P stands for Player)
I thought the console would show this:
1 0 0
1 P 0
1 0 0
But instead it gave me this:
1 0 0
1 P 0
1 0 0
Why are there large spaces between the different arguments?
Upvotes: 2
Views: 1565
Reputation: 473272
As specified in the documentation, print
inserts tabs between each argument, and inserts a newline at the end of what it prints. It is primarily for debugging, and it is a simple tool. If you want more rigid control of what gets printed, use io.stdout:write
.
Upvotes: 3