I guess you want something like this:
import os
from typing import Mapping
from colorama import Fore , init
init()
os.system("cls" or "clear")
clear = lambda: os.system('cls')
# GIVE LIST NUMBER
listed = input(Fore.GREEN+"Please Enter A List Of Number: ")
# CONVERT INPUT(STR) TO LIST:
listed = list(map(int, listed.split(',')))
listed= list(map(int, listed))
#CHEACK SUM IN LIST == 0
if sum(listed) == 0:
print("yes")
Updated (from your comment):
from itertools import combinations
list1 = [3, 2]
list2 = [3, 2, -2, -5]
list3 = [5, -5, 0]
def check_sum(list_of_numbers):
if len(list_of_numbers) >= 3:
subsets = list(combinations(list_of_numbers, 3))
for each_subset in subsets:
if sum(each_subset) == 0:
return "Yes"
return "No"
else:
return "No"
print(check_sum(list1))
print(check_sum(list2))
print(check_sum(list3))
Output:
No
Yes
Yes
Some credits to https://www.geeksforgeeks.org/python-program-to-get-all-subsets-of-given-size-of-a-set/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…