Typeerror: Len() of unsized Object how to resolve

Asked

Viewed 318 times

0

def invert_map(x):
    y = _np.empty_like(x)
    y[x] = _np.arange(len(x))
    return y

Result gives this in this function :

File "E: Anaconda3 lib site-Packages arlpy comms.py", line 74, in invert_map y[x] = _np.arange(Len(x))

Typeerror: Len() of unsized Object

What is your cause? How to solve it?

  • 1

    What the x being passed on to him to shoot that mistake?

  • The function len makes use of the method __len__ therefore x needs to be the type that has the implementation of this method, otherwise this error will be released.

1 answer

0

Probably "x" is not a string.

Try to convert it, like this:

len(str(TestV))
  • 2

    And it should be a string?

  • @Andersoncarloswoss Well thought out, I went straight into the most common usage haha! But the "Len" serves for lists too.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.