绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
为什么输入四位数时,会出错
2019-09-29 17:50:44

list=[]

number=input("Please input end by #:")

whilenumber!='#':

    list.append(number)

    number=int(input("Please input end by #:"))

length=len(list)

fori inrange(0,length-1):

    forj inrange(0,length-i-1):

        iflist[j]>list[j+1]:

            temp=list[j]

            list[j]=list[j+1]

            list[j+1]=temp

print(list)

测试:

Please input end by #:56

Please input end by #:8888

Please input end by #:#

Traceback (most recent call last):

  File "D:/Python/workspace/Pybasis/Buble_sort.py", line 5, in <module>

    number=int(input("Please input end by #:"))

ValueError: invalid literal for int() with base 10: '#'

Process finished with exit code 1

分享好友

分享这个小栈给你的朋友们,一起进步吧。

应用开发
创建时间:2020-06-17 15:31:04
应用软件开发是指使用程序语言C#、java、 c++、vb等语言编写,主要是用于商业、生活应用的软件的开发。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • 栈栈
    专家
戳我,来吐槽~