可变还是不可变?
下面的函数会将某个字符串与其小写版本的映射添加到一个字典中。调用函数后,您认为 d 和 s 的取值分别是什么?
def store_lower(_dict, _string):
"""Add a mapping between `_string` and a lowercased version of `_string` to `_dict`
Args:
_dict (dict): The dictionary to update.
_string (str): The string to add.
"""
orig_string = _string
_string = _string.lower()
_dict[orig_string] = _string
d = {}
s = 'Hello'
store_lower(d, s)
本练习是课程的一部分
