Python程序没有返回任何内容

时间:2017-04-23 17:49:13

标签: python

我练习Python所以我决定为2个数字重新创建max()函数。代码没有错误,它只是没有返回任何内容。请帮忙! `

def newMax(num1, num2):
    if num1 > num2:
        return num1
    elif num2 > num1:
        return num2
    elif num1 == num2:
        return "They're both equal!"
    else:
        return "We've run into some sort of error. Make sure you entered 2 numbers."
print("This program will return the largest of 2 numbers you enter.")
number1 = input("Please enter your first number.")
number2 = input("Please enter your second number.")
newMax(number1, number2)

`

你能不能用变量作为参数调用函数,如果没有,那我该如何编写这个程序? FIGURED OUT,我有一个打印声明错误,抱歉。

1 个答案:

答案 0 :(得分:1)

new_max = newMax(number1, number2)
print(new_max)

尝试将其分配给变量并打印该变量。