On Jul 10, 11:15 pm, ssecorp <[EMAIL PROTECTED]> wrote:
> I don't fully understand why I have to do this.

Because your function is recursive.

You call your function passing it a list of numbers. It generates a
new number and looks to see if it's in the 'placed' list. If it is, it
calls itself again, but if it isn't, it returns the number & an
updated 'placed'.

Without placing a return before the recursive call to validate, it
calls validate in place, ignores its return result, then drops out of
the conditional to the end of the function, where an implicit 'return
None' occurs.

By returning what validate passes back, you in effect pass it back up
the chain of recursive calls, so the final return will _always_ pass
back the number, list combo you require.

- alex23
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to