python list comprehensions; compressing a list of lists?

后端 未结 13 1953
名媛妹妹
名媛妹妹 2020-11-30 01:49

guys. I\'m trying to find the most elegant solution to a problem and wondered if python has anything built-in for what I\'m trying to do.

What I\'m doing is this. I

13条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 02:18

    def flat_list(arr):
        send_back = []
        for i in arr:
            if type(i) == list:
                send_back += flat_list(i)
            else:
                send_back.append(i)
        return send_back
    

提交回复
热议问题