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 201 views
1 answer 184 views
1 answer 185 views
1 answer 182 views
1 answer 150 views
150 views asked Oct 22, 2020 by avibootz
...