That code works for any other case except [[]], why is it so hard to use an if before that and simply return an empty array when the input is exactly that? I don't see the problem.
Anyone here had some success in creating an empty array in Python?
Sure, it's super easy:
empty_list = []
I see that you're trying to turn a list into a string and then parse it back into a list. Are you trying to avoid input mutation? The standard library has a module called copy for that, in particular, you might find the copy.deepcopy function very useful. Docs: https://docs.python.org/3/library/copy.html#copy.deepcopy
That code works for any other case except
[[]]
, why is it so hard to use an if before that and simply return an empty array when the input is exactly that? I don't see the problem.This comment is hidden because it contains spoiler information about the solution
Sure, it's super easy:
I see that you're trying to turn a list into a string and then parse it back into a list. Are you trying to avoid input mutation? The standard library has a module called
copy
for that, in particular, you might find thecopy.deepcopy
function very useful. Docs: https://docs.python.org/3/library/copy.html#copy.deepcopyWrite something like this:
You need to figure out how to properly write that if condition, it's not the literal solution, just some pseudocode.
I wish I could understand. Anyway, thanks for helping.
Short-circuit your code, you won't apply it to that case. Use an if, it's as easy as that.
This comment is hidden because it contains spoiler information about the solution
Why are you not returning an empty list?
[0]
is not an empty list, neither is[None]
. There is no issue, you're not doing what you should do.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution