How can I return two values from a function in Python?

前端 未结 8 682
执笔经年
执笔经年 2020-11-22 12:14

I would like to return two values from a function in two separate variables. For example:

def select_choice():
    loop = 1
    row = 0
    while loop == 1:         


        
相关标签:
8条回答
  • 2020-11-22 12:40

    I think you what you want is a tuple. If you use return (i, card), you can get these two results by:

    i, card = select_choice()
    
    0 讨论(0)
  • 2020-11-22 12:42

    you can try this

    class select_choice():
        return x, y
    
    a, b = test()
    
    0 讨论(0)
提交回复
热议问题