【发布时间】:2017-10-25 02:30:04
【问题描述】:
到目前为止我的代码:
def book_point():
displayoints = 0
books = 0
setmessage()
books = bookinput()
displayoints = display(bookinput)
def setmessage():
print ("Hello, please enter the number of books that you has purchased this month and we will displays the points awarded you have")
def bookinput():
books = 0
books = int(input("Enter number: "))
return books
def display(bookinput):
if bookinput == 0:
print ("You have 0 point")
elif bookinput == 1:
print ("You have 5 points awarded")
elif bookinput == 2:
print ("You have 15 points awarded")
elif bookinput == 3:
print ("You have 30 points awarded")
elif bookinput >= 4:
print ("You have 60 points awarded")
else:
print ("Invalid number")
book_point()
在执行时,它会显示 Traceback(最近一次调用最后一次): 文件“python”,第 29 行,在 book_point 中的文件“python”,第 6 行 文件“python”,第 25 行,显示中 TypeError: 'function' 和 'int' 的实例之间不支持 '>='
【问题讨论】:
-
看起来 bookinput 应该是书籍。 bookinput 是一个函数,那么如何比较 bookinput >= 4?
标签: python-3.x