How can I break down these problems into easier parts?


#1

Question

How can I break down these problems into easier parts?

Answer

This is a key part of problem solving in programming, so be on the lookout for hints about how to break down the problem when going through the instructions. In the digit_sum exercise, we know a few things:

  1. Our function takes some positive integer n as input.
  2. If we convert that input to a string using the built-in str() function, we can iterate through it using a for each loop to get each “character” (digit) in the string.
  3. We can do something with each digit inside of that for each loop.
  4. We must return the result at the end, not inside of the loop.

FAQ: Learn Python - Practice Makes Perfect - digit_sum
#11

2 posts were split to a new topic: Explain why my code wouldn’t be a solution to this exercise?


#14

A post was split to a new topic: Provided digit sum solution is confusing