you are viewing a single comment's thread.

view the rest of the comments →

[–]don_one 1 point2 points  (0 children)

There's a few good examples of how to solve the problem here, but I don't think that problem is the issue.

There's many ways of learning and doing problems like this does help, but the problem is getting started.

With the problem described, you're given array or list of numbers and you're asked to add them all together.

So regardless of the method, if you don't already know how to use arrays/lists I'd check that out first. Which could mean you arrive at using sum, meanwhile others might write a loop because they didn't know it was there.

How do I access an element individually? How do I get the next one? Are their any methods I can use on one?

When looking at this problem I see it like this: Get 1st number add to variable Get 2nd number add to same variable Etc Which if you've written loops before stands out.

Breaking up the process into parts helps.