isinstance() returns a boolean indicating whether the first argument is an instance of the type(s) in the second argument, or a subclass thereof.
what is the use of isinstance function never heard of it.
pep8 was killed
This comment is hidden because it contains spoiler information about the solution
hi newby here and i have a question. Why do we copy the list? I don't understand the reason behind it. Plus this code would fail if there were two strings after one another in the list since the indeces would be shifted after removal of an element and some values would be looked over.
could someone help to explain why this is executed differently than the above solution?? Thanks.
for i in l:
if not isinstance(i, str):
Also, why not using remove() to remove the string from the list?
I think their point was that you shouldn't do one-liners like this for redability reasons (also, isn't it better to just use the function directly, in real code, instead of redeclaring it just to... Rename it?)
But from a solution standpoint, this is amazing
In an interview they would ask you to do this in place.