Ako skontrolovať prázdny zoznam v jazyku python

Príklady kódu

9
0

N

if len(li) == 0:
    print('the list is empty')
9
0

N

my_list = list()
# Check if a list is empty by its length
if len(my_list) == 0:
    pass  # the list is empty
# Check if a list is empty by direct comparison (only works for lists)
if my_list == []:
    pass  # the list is empty
# Check if a list is empty by its type flexibility **preferred method**
if not my_list:
    pass  # the list is empty
8
0

N

a = []

if not a:
  print("List is empty")
8
0

N

# Python program to declare 
# empty list 

# list is declared 
a = []		 
7
0

N

if not a:
  print("List is empty")
2
0

N

list2 = filter(None, list1)

V iných jazykoch

Táto stránka je v iných jazykoch

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................