About 469,000 results
Open links in new tab
  1. python - How do I check if a list is empty? - Stack Overflow

    Anyway, the reason this is bad (and that violating idioms in a language with strong idioms like Python is bad in general) is that it signals to the reader that you're specifically checking the …

  2. How to check if a list is empty in Python? - Stack Overflow

    The API I'm working with can return empty [] lists. The following conditional statements aren't working as expected: if myList is not None: #not working pass if myList is not []: #not workin...

  3. How do I check in python if an element of a list is empty?

    Lets assume we have an empty str within a list: lst = [1, 2,3 , ""], then check whether the list includes ("", []): [print("empty") if i in ("",[]) else i for i in lst] output. empty. You can assign any …

  4. python - How do I check if the list contains empty elements?

    Feb 3, 2016 · If you want to check whether all the elements in the list aren't 'empty' (so if the list contains the string '' it will return False) you can use the built-in function all(): all(v for v in l) …

  5. python - What is the quickest way to check if a list is empty, and in ...

    Edit: With regards to one of the given examples, as noted by @Carcigenicate, any() will fail in select situations if the goal is purely to check if a list is empty. any() will return False "if the list …

  6. Python: How to check if a nested list is essentially empty?

    It is possible to check if a list of lists is empty or not by using len function to check if the list's length equal to zero or not, then use any to give True if there is any True (There is at least one …

  7. python - How to check if a list is empty - Stack Overflow

    Oct 26, 2018 · A more composable/reusable answer would be to make a generator function that flattens nested lists (or for greater reusability, arbitrary iterables), making it trivial to iterate the …

  8. How to check if the string is empty in Python? - Stack Overflow

    You want to check if the user wrote something or not. A good variable name may be not_filled_in. This makes the code very readable. if formfields.name == not_filled_in: raise ValueError("We …

  9. How to check if a variable is empty in python? - Stack Overflow

    I am wondering if python has any function such as php empty function (http://php.net/manual/en/function.empty.php) which check if the variable is empty with …

  10. python - assertTrue () in pytest to assert empty lists - Stack Overflow

    Jun 2, 2016 · Is an empty list the same as another empty list, or is every empty list different? How does my Python version handle that semantic? In the end I prefer to be specific about what I …

Refresh