Code for addition

Steve D'Aprano steve+python at pearwood.info
Fri Aug 4 21:24:57 EDT 2017


On Sat, 5 Aug 2017 12:43 pm, Ode Idoko wrote:

> Can anyone help with the python code that can add 101, 102, 103...2033 please?


Sounds like homework. Here are some hints for you to play around with and see if
you can get the right answer:


sum([101, 102, 103])

range(101, 104)

sum(range(1, 4))


What does sum() do?

What does range() do?

Can you put them together to get the answer you need?



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list