Digit_sum (how do I save arguments in a list?)


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096

Before anyone has time to judge, the reason I'm not presenting code is because I have a template of things I want to do, but I don't know where to start. Here are the steps that I want to go through in order to complete this task:

  1. I want to save the arguments in a list
  2. I want to initialize a count variable
  3. I want to loop through the list
  4. I want to increment the count by each value in the list
  5. I want to return the final count variable

I can visualize how steps 2 - 5 could look like, but I don't know or understand how I could save the function's arguments in a list. I've looked up a few examples online but they're either calling functions from unique modules or it's a slightly different answer than what I'm looking for. Is saving the items in a list a bad approach in general, or am I within the ballpark of how I'm supposed to be handling this? Thanks in advance.


Replace this line with your code.


#3

well, you can do this, but then you would:

convert the digits to string, loop over the string and append the digits to list (don't forget to convert back to integer)

but then the list is pointless, you are better of adding the digits to count while looping over the string


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.