A
A
aqvalite2013-10-15 09:10:01
Python
aqvalite, 2013-10-15 09:10:01

How is 166 obtained?

Can you please explain how 166 is obtained?
A Byte of Python, Python 3.2
Thank you.

def total(initial=5, *numbers, extra_number):
count = initial
for number in numbers:
count += number
count += extra_number
print(count)
total(10, 1, 2, 3, extra_number=50)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2013-10-15
@aqvalite

Maybe because in the first case extra_number is added 1 time (outside the loop), and in the second case 3 times (in the loop)?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question