how to get sum of tuple in python code example
Example: 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