为什么打印功能在Python中不起作用?

时间:2017-09-14 04:53:29

标签: python-3.x

为什么打印方法不能在函数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()

1 个答案:

答案 0 :(得分:1)

因为你没有在main函数中调用total函数

更改你的主要功能,像这样添加总功能

def main():
    firstAge = int(input('Enter your age:'))
    secondAge = int(input("Enter your best friend's age:"))
    total(firstAge,secondAge)