Mutable या immutable?
नीचे दिया गया फंक्शन किसी dictionary में एक string और उसके lowercase वर्ज़न के बीच mapping जोड़ता है. फंक्शन कॉल होने के बाद आप d और s के मान क्या होने की उम्मीद करते हैं?
def store_lower(_dict, _string):
"""`_dict` में `_string` और उसके lowercased वर्ज़न के बीच एक mapping जोड़ें
Args:
_dict (dict): अपडेट करने के लिए dictionary.
_string (str): जोड़ने वाली string.
"""
orig_string = _string
_string = _string.lower()
_dict[orig_string] = _string
d = {}
s = 'Hello'
store_lower(d, s)
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Functions लिखना
इंटरैक्टिव व्यावहारिक अभ्यास
हमारे इंटरैक्टिव अभ्यासों में से किसी एक के साथ सिद्धांत को व्यवहार में बदलें
अभ्यास शुरू करें