Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started