#recursive list method

16 messages · Page 1 of 1 (latest)

wide badgeBOT
#

@drowsy hazel

blig Uploaded Some Code

Need help with a method for a recursive list I'm supposed to write.
It's the insert method, my attempt doesn't work. I used a helper method called _insert_first and I can't tell which one causes the errors. It's an error saying that None type doesn't have str or insert method.

I thought of copy pasting the code, but to get context I think it's better to just post the whole file with the whole class included (hope this is allowed).

Uploaded these files to a Gist
proud pecan
#

Can you share the full error output?

drowsy hazel
wide badgeBOT
#

@drowsy hazel

blig Uploaded Some Code

for context, these errors are what comes up for the insert method doctests

Uploaded these files to a Gist
proud pecan
#

You need to check if _rest is not None before doing anything with it.

drowsy hazel
#

I tried to rewrite the two methods because putting an elif statement with the requirement you mentioned didn't solve the problem, so I started from the most basic thing I could write and a docstring to test... the most basic operation won't work for some reason

#

one sec I'll send the info

#

that's all I wrote

#

I'll send the result one moment

drowsy hazel
#

nvm I forgot the underscore in _insert_first

#

alright so the helper method works

#

the main function works too

#

the problem was that I had to specify in the base case that self._rest equals a new instance of RecursiveList