python tuple sum

Solutions on MaxInterview for python tuple sum by the best coders in the world

showing results for - "python tuple sum"
Samuel
13 May 2017
1test_tup = (7, 8, 9, 1, 10, 7)
2print("The original tuple is : " + str(test_tup)) 
3# > The original tuple is : (7, 8, 9, 1, 10, 7)
4res = sum(list(test_tup)) 
5print("The summation of tuple elements are : " + str(res)) 
6# > The summation of tuple elements are : 42
7test_tup = ([7, 8], [9, 1], [10, 7]) 
8res = sum(list(map(sum, list(test_tup)))) 
9print("The summation of tuple elements are : " + str(res)) 
10# > The summation of tuple elements are : 42