Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursive functions
#2
The output list that is defined at line 26 should be defined inside the body of the ancestors() function otherwise all the calls to ancestors() will share the same output list and this can only fail. Each time the function is called, a new output list must be created.

Then at line 31, you are computing the ancestors of the candidate by a recursive call but you are not doing anything with the list of ancestors that is returned by that call. If you don't use the result, this call is unnecessary, or perhaps there is something to change in the code.
Reply


Messages In This Thread
Recursive functions - by Ayman_2001 - Jun-27-2020, 10:37 AM
RE: Recursive functions - by Gribouillis - Jun-27-2020, 12:02 PM
RE: Recursive functions - by Ayman_2001 - Jun-27-2020, 01:17 PM
RE: Recursive functions - by ndc85430 - Jun-27-2020, 03:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python recursive functions Ayman_2001 6 2,685 Jun-24-2020, 07:54 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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