I have been trying to understand recursion. But I don't think I've quite got a hang of it.
Here the outline for my code:
def f():
used = [anything]
new = []
while i < something:
new.append(i)
i += 1
for i in new:
if i in used:
f()
else:
return new
Now, I don't think I can use this because I'm not iterating and there is no base case. I need to keep running this program till I get a set of values (picked randomly) that are not in used. What would be the best way to achieve that? Create another function?
Any help would be greatly appreciated.
Thanks!
used?fis trying to do, so I can't be of too much help, but one possible area of trouble is where youreturn newin theelseclause. That would return right away. And since you don'treturn f()in theif i in usedblock, you always returnNone