哪里有问题
num=random.randint(1,1000)i=1
while True:
n = input('guess the num')
if list(n).isalpha() or list(n).isalnum:
print('enter the true figuer only')
else:
n=int(n)
if n < 1 or n > 1000:
print('enter the true figuer only')
elif n==num:
print('great,u have try %d times'% i)
elif n > num:
print('big')
i=i+1
else:
print('small')
i=i+1
猜大小的 哪里有错呢 import random
num=random.randint(1,1000)
i=1
while True:
n = input('guess the num')
if not(n.isdigit()):
print('enter the true figuer only')
else:
n = int(n)
if n < 1 or n > 1000:
print('enter the true figuer only')
elif n==num:
print('great,u have try %d times'% i)
elif n > num:
print('big')
i=i+1
else:
print('small')
i=i+1 https://www.runoob.com/python/att-string-isalnum.html
页:
[1]