I don't know which of the decimal creation codes is wrong.

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

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):
    numlist = list(combinations(nums, 3))
    for eachtuple in numlist:
        newlist = list(eactuple)
        n = newlist[0]+newlist[1]+newlist[2]

    for n in n_list:
        for j in range(2, n):
            if n%j==0:
    return len(newset)


2022-09-20 14:46

1 Answers

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

If you have any answers or tips

© 2022 pinfo. All rights reserved.