Skip to content

Instantly share code, notes, and snippets.

@adrianmarkperea
Created October 5, 2019 03:32
Show Gist options
  • Save adrianmarkperea/8a6e66a157e07461f838b1373d3fe9c6 to your computer and use it in GitHub Desktop.
Save adrianmarkperea/8a6e66a157e07461f838b1373d3fe9c6 to your computer and use it in GitHub Desktop.
my_list = []
if not my_list:
print('List is empty')
# This could also work, but is unnecessary
if len(my_list) == 0:
print('List is empty')
my_list.append(1)
if my_list:
print('List is not empty')
# outputs:
List is empty
List is empty
List is not empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment