PPA-3
Question
Write the following functions:
is_key
: accept a dictionaryD
and a variablekey
as arguments. ReturnTrue
if the variable key is a key of the dictionaryD
, andFalse
otherwise.value
: accept a dictionaryD
and a variablekey
as arguments. If the variablekey
is not a key of the dictionaryD
, returnNone
, otherwise, return the value corresponding to this key.
You do not have to accept input from the user or print the output to the console. You just have to write the definition of both the functions.
Hint
key in D
evaluates to True
if key
is one of the keys and False
otherwise.