my_dict={'a':'One','b':'Two','c':'Three'}
k=my_dict.keys()
print(k)
Output is here
dict_keys(['a', 'b', 'c'])
my_dict={'a':'One','b':'Two','c':'Three'}
k=my_dict.keys()
print(k)
my_dict['d']='Four' # one key value pair added
print(k) # changes are reflected.
Output
dict_keys(['a', 'b', 'c'])
dict_keys(['a', 'b', 'c', 'd'])
my_dict = {'a': 'One', 'b': 'Two', 'c': 'Three'}
for key in my_dict.keys():
print(key)
Use Case: Checking If a Key Exists:if 'b' in my_dict.keys():
print("Key 'b' is present")
Difference Between keys() and Direct Access:Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.