def hotel_cost(nights):
return nights * 140
bill = hotel_cost(5)
def add_monthly_interest(balance):
balance * (1 + (0.15 / 12))
def make_payment(payment, balance):
new_balance = add_monthly_interest(balance)
print "You still owe: " + str(new_balance)
make_payment(100,hotel_cost(5))
这是印刷“你还欠:没有”,我觉得我只是错过了一些非常基本的东西。我已经是最新的了。Python是我的第一语言,除了像我们这一代人一样精通技术之外,没有其他真正的计算机知识。你知道吗
add_monthly_interest
需要一个return语句。你知道吗没有return语句的函数(或者实际上,在执行结束时)返回
None
。这是发生在:所以,你得到
None
,然后打印出来。您希望在该函数中使用return
,与其他一些语言不同,python不返回最后一个表达式的值。你知道吗add_monthly_interest
不返回任何内容,因此Python让它自动返回None
。必须返回表达式的结果:相关问题 更多 >
编程相关推荐