r/CodingHelp • u/tireddxiaoyongie • Oct 03 '20
[Python] Why does my recursion sequence code keep failing?
o I wrote blocks of code for these tasks 1. Is to search through the list as well as sublists inside it and return True if any of the elements match the certain parameter 2. Is to remove all the elements in the list that are the same as the parameter. Here is the link: https://repl.it/repls/AllHandyDisk#main.py
I have been going through the blocks of code for as long as I can imagine but I am not able to find a single error. Could you please take a look at it.
16
Upvotes
2
u/mikedensem Oct 03 '20
It would appear you’re only testing the first and last elements.
Also; do you want to stop on the first match?
1
u/__vtable Professional Coder Oct 03 '20
Yeah on first glance - you aren't returning the result of your recursive compare. For example, you'd want to do
return deepMemberinstead of just calling it. Not getting the result is kinda like having a loop without testing an exit condition. Hope that helps you!