CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #5
    Join Date
    Nov 2015
    Posts
    6

    Re: How to keep list local to the function call (Recursion) in Python

    Quote Originally Posted by laserlight View Post
    I don't see a list(check) in your code, or any other way that you are making a copy of the list.

    What I do see is you adding a check for an empty list, but if you want to do that, I suggest:
    Code:
    def coin_change_count(C, check=None):
        # if not empty list, setup a new check list local to function
        if check is None:
            check = [0, 0, 0, 0]
        # ...
    then to call it:
    Code:
    coin_change_count(N)

    I can see that the test input is hard coded, I can run the program to obtain the actual output, but what is the expected output?
    I tried putting

    Code:
    check = list(check)
    at start of the function, But still didn't worked. Here is the expected Output.
    Code:
    >> [[2, 0, 0, 1], [0, 0, 2, 0], [1, 1, 1, 0], [2, 2, 0, 0], [4, 0, 0, 0]]
    5
    Last edited by atinesh229; November 8th, 2015 at 10:46 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured