相关疑难解决方法(0)

如何从Python中的函数返回两个值?

我想从两个单独的变量中的函数返回两个值.例如:

def select_choice():
    loop = 1
    row = 0
    while loop == 1:
        print('''Choose from the following options?:
                 1. Row 1
                 2. Row 2
                 3. Row 3''')

        row = int(input("Which row would you like to move the card from?: "))
        if row == 1:
            i = 2
            card = list_a[-1]
        elif row == 2:
            i = 1
            card = list_b[-1]
        elif row == 3:
            i = 0
            card = list_c[-1]
        return i
        return card
Run Code Online (Sandbox Code Playgroud)

我希望能够分别使用这些值.当我尝试使用时return i, card,它返回一个tuple …

python return function list return-value

189
推荐指数
5
解决办法
40万
查看次数

标签 统计

function ×1

list ×1

python ×1

return ×1

return-value ×1