Sobes.tech
Intern — Middle

Determining the key status in a dictionary and displaying the corresponding message

livecode

Task condition

It is necessary to verify whether the logic that determines if a key is suitable, unsuitable, or in a draft state is correctly implemented, and also whether it correctly handles the values True, False, and None.

# True — correct key
# False — incorrect key
# None — draft key

mapping = {
    'key0': True,
    'key1': False,
    'key2': True,
    'key3': None,
    'key4': None,
    'key5': False
}

val = mapping.get('key2')

if val:
    print('The key is suitable!')
elif not val:
    print('The key is not suitable!')
else:
    print('This is a draft key!')