File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Writing Functions in Python Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -177,3 +177,25 @@ def median(values):
177177
178178 **************************************************************************************************************************************************************"""
179179## Mutable or immutable?
180+
181+ """----What do you expect the values of d and s to be after the function is called?"""
182+
183+ def store_lower (_dict , _string ):
184+ """Add a mapping between `_string` and a lowercased version of `_string` to `_dict`
185+
186+ Args:
187+ _dict (dict): The dictionary to update.
188+ _string (str): The string to add.
189+ """
190+ orig_string = _string
191+ _string = _string .lower ()
192+ _dict [orig_string ] = _string
193+
194+ d = {}
195+ s = 'Hello'
196+
197+ store_lower (d , s )
198+
199+ # d = {'Hello': 'hello'}, s = 'Hello'
200+ """!!!
201+ Dictionaries are mutable objects in Python, so the function can directly change it"""
You can’t perform that action at this time.
0 commit comments