The error above occurred, and the code below is the one I wrote.

"We want to find the number of prime numbers when we add three of the given numbers. When an array nums containing numbers is given as a parameter, complete the solution function to return the number of decimal cases by selecting three different numbers from the nums

I was writing a code related to

The list has elements (as shown in the picture above, n_list contains elements), and I'm not sure why the error says n_list does not have elements.

I'd really appreciate your help. Thank you for reading!

```
from itertools import combinations
def solution(nums):
n_list=[]
numlist = list(combinations(nums, 3))
for eachtuple in numlist:
newlist = list(eactuple)
n = newlist[0]+newlist[1]+newlist[2]
n_list.append(n)
print(n_list)
for n in n_list:
for j in range(2, n):
if n%j==0:
n_list.remove(n)
else:
pass
newset=set(n_list)
return len(newset)
```

2022-09-20 14:46

It's a simple issue.

It's 1 out of 10 divided by 2, except for yourself
It was erased at 2, but I tried to erase it at 5, so it's not there.
You'll find out if you actually put `print(j)`

in `ifn%j == 0:`

.

Other than that, if you do it in the above way, please note that there are other mistakes

2022-09-20 14:46

Popular Tags

© 2022 pinfo. All rights reserved.