python output unexpected behaviour
Following program is used to sort a list
for i in range(len(q)):
for j in range(len(q)):
if not (q[i] < q[j]):
t = q[i]
q[i] = q[j]
q[j] = t
contents of q are : {-1 2 4}
The output I get has one empty number like:
4
-1 2
i.e. extra number (empty) between 4 and -开发者_如何学JAVA1. What am I doing wrong?
You want to sort a list?
your_list.sort()
精彩评论