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

前端 未结 8 685
执笔经年
执笔经年 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:22

    And this is an alternative.If you are returning as list then it is simple to get the values.

    def select_choice():
        ...
        return [i, card]
    
    values = select_choice()
    
    print values[0]
    print values[1]
    

提交回复
热议问题