这是我第一次上编程课,我很难解决这个问题。我似乎无法实现我一直在获取“TypeError:unsupported operandom type for+:'int'and'NoneType”
def woodtype(wood):
MAH=float(75.00)
OAK=float(100)
coffetab=float(0)
if woodtype=="mahogany":
coffetab=MAH
else:
if woodtype=="oak":
coffetab=OAK
lamp=65
tables=155
print("the cost per desk lamp is $%.2f" %lamp)
print("the cost per coffee table is $%.2f" %tables)
dl=input("how many desk lamps are you buying?:")
desklamps=int(dl)
cf=input("how many coffee tables are you buying?:")
coffeetables=int(cf)
print("what type of wood would you like the coffee tables; mahogany, oak or pine.")
wood=input("what type of wood for your coffee tables?:")
costofwood=woodtype(wood)
total= (desklamps*65)+(coffeetables*(15+costofwood))
print("the total cost of your purchase is $%.2f" %total)
您的函数
woodtype
似乎缩进不良,并且没有返回语句,因此它返回None
。在通过添加退货,您应该能够解决问题,例如
相关问题 更多 >
编程相关推荐