How to add all items in a tuple with Python

2 Answers

0 votes
tpl = (1, 2, 3, 4)

result = sum(tpl)

print(result)


'''
run:

10

'''

 



answered Dec 17, 2018 by avibootz
0 votes
tpl = (1, 2, 3, 4)

result = sum(tpl, 8)

print(result)


'''
run:

18

'''

 



answered Dec 17, 2018 by avibootz

Related questions

1 answer 210 views
1 answer 188 views
1 answer 198 views
1 answer 197 views
1 answer 159 views
159 views asked Oct 22, 2020 by avibootz
...