python中大于0怎么表示_python 做一个循环 要求输入大于0的数字 判断其不为负数或者字母...

python 做一个循环 要求输入大于0的数字 判断其不为负数或者字母

heyandc LV12 2013-11-25

def Setlimits(): print ('Starting Game limits') print ('Low must be 0 or greater. High must be greater than low.') left=input('Please enter a Low bound: ') def Low1(x): while x < 0: x = int (input('... def Setlimits():

print ('Starting Game limits')

print ('Low must be 0 or greater. High must be greater than low.')

left=input('Please enter a Low bound: ')

def Low1(x):

while x < 0:

x = int (input('Low bound must be 0 or greater: '))

return print('Low bound is ',x)

def Low2(x):

Low(x)

def Low(x):

while True:

try:

y=int(x)

if y < 0:

y = int(input('Low bound must be 0 or greater: '))

Low1(y)

break

else :

print('Low bound is ',y)

break

except ValueError:

y=int(input('Low bound must be a valid integer:'))

Low2(y)

Low(left)

Setlimits()

麻烦看下我写的这个 连续输入2个字符就会出错 输入一个负数后再输字符 又需要输入2次正数。。。好多问题 展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值