开发者

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜