Question: def incrementKeyCount ( D , key ) : ' ' Function that takes in a Dictionary object ( D ) containing KEY: VALUE pairs where
def incrementKeyCount key:
Function that takes in a Dictionary object D containing KEY: VALUE
pairs where the VALUE is a count representing the number of times the KEY
is incremented.
If the parameter key does not exist in D then a new KEY: VALUE
pair is created in D with key:the first time the key is incremented
If the parameter key does exist in D then the key's VALUE is
incremented by
Note that since dictionaries are mutable, this function does
not return a value.
Consider using the in operator to check if a key exists in a Dictionary
Assert examples below illustrate correct behavior for this function
# COMPLETE YOUR FUNCTION DEFINITION HERE
dict
assert lendict
assert incrementKeyCountdictCS None
assert lendict
assert CS in dict True
assert dictCS
assert incrementKeyCountdictCS None
assert lendict
assert dictCS
assert incrementKeyCountdict "MATHA None
assert lendict
assert MATHA in dict True
assert dictMATHA
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
