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 207 views
1 answer 187 views
1 answer 193 views
1 answer 193 views
1 answer 156 views
156 views asked Oct 22, 2020 by avibootz
...