Python Forum

Full Version: How to pass value from method to function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I really don't understand your confusion. Your previous post show that you understand how to pass argument to a function.
your function signature should look like this

def list_length(single_method_list)

so it's name must be list_length as that is the name expected by the test case. It takes one argument - single_method_list. It must be instance of SingleMethodList class defined in another module (single_method_list.py file). Note that you should stick to the name of the class as given to you because the test case will try to instantiate variable s_list of this class.
So the problem I am having, and now i have followed what everyone is saying, is that it is passing None to the function, so after testing, I get on all but the empty list test in my test suite
Unbound error variable 'first' referenced before assignment 
Which implies to me that it is completely missing tie if statements which I don't understand. when i run my original code, it does what I expect, yet take it out of the function and pass it to the function, and it all falls apart.

Have I not converted everything to python3 correctly?

Ah, I have a break through, thank you all for your help, I changed the range x was working on to 0, and another test was passed, it now only fails on an empty list and single item list which is what I was expecting it to do, as I had not written the code to deal with that yet. Thank you very much for your help. I think I nearly get it now.
Pages: 1 2