我在网上寻找了解决方案,但没有找到相关的内容。我的课程作业要求我制作一个程序,让计算机尝试猜测用户输入的数字。这个数字需要在001到100之间,因此我开始努力确保用户只能输入该范围内的数字。
我目前的代码:
import random
code=(int(input("Input a three digit code. Must be more than 001 and less than 100.")))
print(code)
if (code < 001) or (code > 100):
print ("Invalid code")
elif (code > 001) or (code < 100):
print ("Valid code")
将001更改为1后程序可以正常运行,但如果我用001运行它,会出现无效令牌错误。 需要在Python 3.4.3中完成此操作。 非常感谢任何形式的帮助。