I have a dictionary my_dict1
, which contains a key 'Error'
I also have another dictionary my_dict2
that either has multiple keys, or is empty. I want to have an if statement that checks whether my_dict1['Error']
is False and check if my_dict2
has any content in it. The code is as follows:
my_dict1 = {'Error': False}
my_dict2 = {'somekey': True}
if my_dict1['Error'] == False:
if len(my_dict2) > 0:
print('ok')
else:
print('no')
This code results in 'ok' as expected.
if my_dict1['Error'] == False & len(my_dict2)> 0:
print('ok')
else:
print('no')
This results in 'no'. Am I understanding the & statement wrong?