首页 > 编程语言 > 详细

python练习

时间:2015-12-17 19:24:23      阅读:281      评论:0      收藏:0      [点我收藏+]

练习1

让用户一直输入数字,如果输入的不是数字就报错,如果输入pc就退出并算出数字之和

#!/usr/bin/evn python
total = 0
while True:
    input = raw_input(‘input something: ‘)
    if input.isdigit():
        total += int(input)
    elif input == ‘pc‘:
        break
    else:
        print "error"
print total


本文出自 “不抛弃!不放弃” 博客,请务必保留此出处http://thedream.blog.51cto.com/6427769/1725722

python练习

原文:http://thedream.blog.51cto.com/6427769/1725722

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!