Python Forum
Help on adding two lists recursively
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help on adding two lists recursively
#4
so I applied my eqSize function and the result I get from adding these two lists:
list1 = ["123", "001", "234", "567"]
list2 = ["007", "894", "561"]
is ['124', '009', '129', '128'] which is almost correct except the first element should be 123 not 124, and I have no clue why it's doing that. My best guess is that there is something wrong with my carryout.

All I had to do is add an else statement to the if statement that dealt with carryout in the add function:
if(len(nStr) > ND):
            carryout = int(nStr[0])
            n = int(nStr[1:])
        else:
            carryout=0
Sorry for all the mini reiplies. I guess I should try to figure it out more before I post.
Reply


Messages In This Thread
RE: Help on adding two lists recursively - by Metalman488 - Sep-16-2018, 08:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Modifying a dictionary recursively SpongeB0B 2 352 May-12-2024, 04:09 PM
Last Post: Gribouillis
  How to return the next page from json recursively? sandson 0 1,262 Apr-01-2022, 11:01 PM
Last Post: sandson
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,248 Jan-07-2022, 07:38 PM
Last Post: cubangt
Star Recursively convert nested dicts to dict subclass Alfalfa 1 3,043 Jan-22-2021, 05:43 AM
Last Post: buran
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,579 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Python script that recursively zips folders WITHOUT nesting the folder inside the zip umkc1 1 3,050 Feb-11-2020, 09:12 PM
Last Post: michael1789
  How to get full path of specified hidden files matching pattern recursively SriRajesh 4 4,142 Jan-18-2020, 07:12 PM
Last Post: SriRajesh
  Adding markers to Folium map only adding last element. tantony 0 2,273 Oct-16-2019, 03:28 PM
Last Post: tantony
  Find a given file recursively inside a directory alinaveed786 1 2,048 Jul-01-2019, 01:53 PM
Last Post: ichabod801
  adding lists to lists? ivinjjunior 5 3,282 Apr-15-2019, 07:41 PM
Last Post: ivinjjunior

Forum Jump:

User Panel Messages

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