为什么我在函数中添加了2个必要的位置参数,却缺少了2个?[重复]

问题描述 投票:0回答:1

我曾试过在函数中把变量改成整数,但没有成功。我也不想把它变成一个全局函数。

# Finds the max size of another angle in the triangle

side1 = input("First side:  ")
side2 = input("Second side:  ")

side1 = int(side1)
side2 = int(side2)

def nextEdge(side1, side2):
    maxLength = (side1 + side2)
    return maxLength

nextEdge()

print(maxLength)
python python-3.x
1个回答
1
投票

你在调用 nextEdge 时没有任何参数。你对 nextEdge 的调用应该是这样的。

maxLength = nextEdge(side1, side2)
© www.soinside.com 2019 - 2024. All rights reserved.