. Advertisement .

..3..

. Advertisement .

..4..

As advised, I used some code samples in another forum, but it could not improve the problem. My question is the “valueerror: min() arg is an empty sequence” in python-how to solve it? The command line is:

`min(x for x in matr_sum[i] if x > 0 if is_visited[k] is False )`

```
for k in range(4):
if matr_sum[i][k] == min(x for x in matr_sum[i] if x > 0 if is_visited[k] is False ) and i!=k:
return k
```

`min(x for x in matr_sum[i] if x > 0)`

and the result:

`min() arg is an empty sequence`

What does the message mean? Can you advise me to fix it? If you have other better answers, leave them in the answer box below.

The cause:This error occurs because no integers appear in your function, so

`min()`

function cannot find any values and it throws an error ”min() arg is an empty sequence”.Solution:If you want this error disappear, you need to provide integers for the

`min()`

method or in the call, you can set the default keyword argument for the`min()`

function.You can use

`default`

to prevent thisValueErrorfrom occurring in general. This argument will be returned if the`min()`

argument is empty. is described here.This only works with Python 3.4+