为什么打印方法不能在函数total中工作?
def main():
firstAge = int(input('Enter your age:'))
secondAge = int(input("Enter your best friend's age:"))
def total(firstAge,secondAge):
response = sums(firstAge,secondAge)
print(response)
def sums(num1, num2):
result = int(num1 + num2)
return result
main()
答案 0 :(得分:1)
因为你没有在main函数中调用total函数
更改你的主要功能,像这样添加总功能
def main():
firstAge = int(input('Enter your age:'))
secondAge = int(input("Enter your best friend's age:"))
total(firstAge,secondAge)