rackNo = 0
while (rackNo > 60) or (rackNo < 1) :
rackNo = raw_input("Enter the Rack number you are using: ")
if (rackNo > 60) or (rackNo < 1) :
print "Rack number must be between 1 and 60"
The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily. You can control comparison behavior of objects of non-built-in types by defining a __cmp__ method or rich comparison methods like __gt__, described in section Special method names.
The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, the == and != operators always consider objects of different types to be unequal, while the <, >, >= and <= operators raise a TypeError when comparing objects of different types that do not implement these operators for the given pair of types. You can control comparison behavior of objects of non-built-in types by defining rich comparison methods like __gt__(), described in section Basic customization.
将字符串(from
raw_input
)与整数进行比较。在最终,你想要的是:
在python2.x中,内置类型之间的比较(
>
,<
)依赖于实现。在python3.x中,这些比较是明确禁止的。在(python2.x documentation)
(python3.x documentation)
相关问题 更多 >
编程相关推荐