ミュータブルかイミュータブルか?
次の関数は、文字列とその小文字版との対応関係を辞書に追加します。関数を呼び出した後、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)
この演習はコースの一部です
