使用条件函数,定义条件

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

我有一个愚蠢的问题。我写了一个定义,我不知道如何引入条件函数。

我有一个有效的定义:

def function_1 (kot):
     if kot == True:
         print ("Yes:")
     else:
         print ("NO:")

效果不错

function_1 (False)

否:

function_1 (True)

是:

但是我想在我的定义中有这样的事情

def function_1 (kot = True):
     if kot == True:
         print ("Yes:")
     else:
         print ("NO:")

并且它不再起作用。每个提示都会得到奖励!

if-statement definition
1个回答
1
投票

因为您需要像上例一样调用该函数

def function_1 (kot=True):
 if kot == True:
     print ("Yes:")
 else:
     print ("NO:")

function_1()

输出:

Yes:
© www.soinside.com 2019 - 2024. All rights reserved.