In: Computer Science
In python Consider the tuple t = (2,3,4,5). Write a function tuList( t ) that takes in a tuple, makes a list out of it, and also creates a new list of all possible sums of elements of the list
Please give thumbs up, thanks
code:
def tuList(t):
L=list();
for i in t:
L.append(i);
SumList=list();
n=len(L);
for i in range(n):
for j in range(n):
if i!=j:
sumvalue=L[i]+L[j];
if sumvalue not in SumList:
SumList.append(sumvalue);
print("Tuple : ",t);
print("List : ",L);
print("List of All Possible Sums: ",SumList);