luoyanhanhan 2016-08-23 11:23 采纳率: 0%
浏览 6940

TypeError: 'int' object is not iterable

def quick_sort(lst,l,r):
    if(l<r):
        i=l,j=r,x=lst[l]
        while(i<j):
            while(i<j and lst[j]>=x):
                j-=1
            if(i<j):
                lst[i]=lst[j]
                i+=1
            while(i<j and lst[j]<x):
                i+=1
            if(i<j):
                lst[j]=lst[i]
                j-=1
        lst[i]=x
        quick_sort(lst,l,i-1)
        quick_sort(lst,i+1,r)




if __name__ == '__main__':
    lst=[5,3,12,63,25,78,17,19,60]
    quick_sort(lst,0,len(lst)-1)
    for item in lst:
        print item

报错信息:
Traceback (most recent call last):
File "C:/Users/LYH/PycharmProjects/untitled7/sort.py", line 22, in
quick_sort(lst,0,len(lst)-1)
File "C:/Users/LYH/PycharmProjects/untitled7/sort.py", line 3, in quick_sort
i = l, j = r,x = lst[l]
TypeError: 'int' object is not iterable

请问我在哪里将int进行了迭代?

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-08-23 11:57
    关注

    s[i]=x
    s在哪里定义的?

    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块