num = [100,1,82,-1]
print(sorted(num))
The above piece of code give the following output: [-1, 1, 82, 100]
.
However, I need it to be like [-1,1,82,100]
.
But so far I have been unable to figure out why does Python add whitespaces in a list with any kind of list operation!
Even a simple addition, or list methods like extend()
, sort()
, etc provide an output with leading whitespaces.
Although they shouldn't really matter, I am trying to solve a leetcode question, where my answer is getting rejected due to these leading whitespaces.