为了账号安全,请及时绑定邮箱和手机立即绑定

Anaconda里KeyboardInterrupt

Anaconda里KeyboardInterrupt

慕标琳琳 2018-08-16 10:09:43
如题,本人写了一个求1-100的奇数代码,出现如下报错,求大神支招n=1while n<101:    num = n % 2    if num==0 :        pass    else:        print (n)        n=n+1print ('end') KeyboardInterrupt                         Traceback (most recent call last)<ipython-input-35-d0485a6ca3d8> in <module>()      1 n=1      2while n<101:----> 3     num = n %2      4     if num==0:      5         passKeyboardInterrupt: 
查看完整描述

1 回答

?
白衣染霜花

TA贡献1796条经验 获得超10个赞

count = 0while (count < 101): if count%2 != 0:   print 'The count is:', count
 count = count + 1print "Good bye!"

没用过python 你的安装环境或者包什么的有没有问题我不知道,但是我能肯定你的循环写的有问题,n=n+1在else里面,那么应该跳不出循环,上面是我看教程写的能在线运行的代码。


查看完整回答
反对 回复 2018-09-11
  • 1 回答
  • 0 关注
  • 1723 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信