my_dict = {'name': 'John', 'age': 30, 'city': 'New York'}
for key in my_dict:
print(key)
name
age
city
keys()
` method to get a list of all the keys in the dictionary and then iterate over the list :my_dict = {'name': 'John', 'age': 30, 'city': 'New York'}
for key in my_dict.keys():
print(key)
name
age
city