What is the easiest way to check to see if a list or dict exists in python ?
Im using the following but this isn't working:
if len(list) == 0:
print "Im not here"
Thanks,
What is the easiest way to check to see if a list or dict exists in python ?
Im using the following but this isn't working:
if len(list) == 0:
print "Im not here"
Thanks,
s = set([1, 2, 3, 4])
if 3 in s:
print("The number 3 is in the list.")
else:
print("The number 3 is NOT in the list.")
You can find more about it here: https://docs.quantifiedcode.com/python-anti-patterns/performance/using_key_in_list_to_check_if_key_is_contained_in_a_list.html