从另一个函数调用一个函数与从另一个函数返回一个函数

时间:2019-06-16 17:16:38

标签: python python-3.x

我想知道我们有什么更好的选择,例如调用诸如help()的功能或返回诸如return help()的功能,以及什么时候该变得更好呢?

我的原始代码:

while True:


def help():
    print('C - to create new list, D - to delete existing list, L - see all your lists')
    return welcome()

def clist():
    c = input('Choose name for our list: ')
    c = []
    return(c)

def welcome():
    w = input('Choose action, press H for help: ')
    if (w == 'h'):
        return help()

welcome()

可以更改为什么:

while True:


def help():
    print('C - to create new list, D - to delete existing list, L - see all your lists')
    welcome()

def clist():
    c = input('Choose name for our list: ')
    c = []
    return(c)

def welcome():
    w = input('Choose action, press H for help: ')
    if (w == 'h'):
        help()

welcome()

0 个答案:

没有答案