[英]Using an argument from another function - Python
Let's suppose I have 假设我有
def perrin(a):
if true:
#Do something
def sequence(string,n)
if string == "name":
perrin(n)
I just want perrin to take the n argument from the sequence, is this the correct way of doing it? 我只希望perrin从序列中获取n参数,这是正确的方法吗?
Yes it's fine you need only to edit two syntax errors: 是的,您只需编辑两个语法错误就可以了:
Capital 'T' in True
True
大写字母“ T”
Colon ( :
) after the function definition def sequence(string, n)
. 冒号(
:
)之后的函数定义def sequence(string, n)
The updated code looks like this 更新后的代码如下所示
def perrin(a):
if True:
#do something here
def sequence(string,n):
if string == "name":
perrin(n)
If both definitions are in the same class it looks fine to me. 如果两个定义都在同一个类中,对我来说很好。 You do need to have True or False with a capital letter, else it won't regocnize is aa boolean.
您的确需要带大写字母的True或False,否则布尔值将不会重新定位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.