min() arg is an empty sequence

前端 未结 4 1173
逝去的感伤
逝去的感伤 2021-02-20 07:32

I\'m trying to find minimum element in matrix row, but there are two conditions: 1) it must be > 0 2) and this point must be not visited(is_visited[k] is False) I\'

4条回答
  •  遥遥无期
    2021-02-20 07:51

    If you want to avoid this ValueError in general, you can set a default argument to min(), that will be returned in case of an empty list. See described here.

    min([], default="EMPTY")
    # returns EMPTY
    

    Note that this only works in Python 3.4+

提交回复
热议问题