Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help in hoemwork
#15
I recently just picked up python so I may not have the best answer...I have already solved it though.

My code has 2 functions. One function to count how many digits are in the number and another function that adds the digits in a number together.
I used a FOR loop to iterate through the number , adding each individual digit to a list. After that I made a variable to hold the sum of the numbers in the list.
My digit counting function counts the digits of the "final answer" , I then used a IF/ELSE statement to determine whether the digits could be added together further. If not return the "final answer" if yes then repeat.
Reply


Messages In This Thread
help in hoemwork - by maayan11 - Apr-08-2017, 05:47 AM
RE: help in hoemwork - by micseydel - Apr-08-2017, 06:39 AM
RE: help in hoemwork - by ichabod801 - Apr-08-2017, 12:49 PM
RE: help in hoemwork - by harrington40 - Apr-08-2017, 04:43 PM
RE: help in hoemwork - by ichabod801 - Apr-08-2017, 06:06 PM
RE: help in hoemwork - by maayan11 - Apr-08-2017, 08:03 PM
RE: help in hoemwork - by ichabod801 - Apr-08-2017, 09:47 PM
RE: help in hoemwork - by maayan11 - Apr-09-2017, 06:35 AM
RE: help in hoemwork - by wavic - Apr-09-2017, 06:38 AM
RE: help in hoemwork - by volcano63 - Apr-17-2017, 06:59 PM
RE: help in hoemwork - by maayan11 - Apr-09-2017, 06:46 AM
RE: help in hoemwork - by wavic - Apr-09-2017, 06:57 AM
RE: help in hoemwork - by maayan11 - Apr-09-2017, 07:10 AM
RE: help in hoemwork - by wavic - Apr-09-2017, 07:33 AM
RE: help in hoemwork - by ichabod801 - Apr-09-2017, 10:52 AM
RE: help in hoemwork - by smbx33 - Apr-17-2017, 02:43 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020