Answers for "python tuple sum"

0

python tuple sum

test_tup = (7, 8, 9, 1, 10, 7)
print("The original tuple is : " + str(test_tup)) 
# > The original tuple is : (7, 8, 9, 1, 10, 7)
res = sum(list(test_tup)) 
print("The summation of tuple elements are : " + str(res)) 
# > The summation of tuple elements are : 42
test_tup = ([7, 8], [9, 1], [10, 7]) 
res = sum(list(map(sum, list(test_tup)))) 
print("The summation of tuple elements are : " + str(res)) 
# > The summation of tuple elements are : 42
Posted by: Guest on March-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language