There are several ways in Looping Dictionary Items
keys() method :
Returns all the keys
Python
student = { "name": "Ram", "age": 21, "course": "B.Tech" } for key in student.keys(): print(key) #output 'name' 'age' 'course'values() method :
Returns all the values
Python
student = { "name": "Ram", "age": 21, "course": "B.Tech" } for value in student.values(): print(value) #output 'Rahul' 21 'B.Tech' items() method :
Returns the key and values together
Python
student = { "name": "Ram", "age": 21, "course": "B.Tech" } for key, value in student.items(): print(key, "=", value) #output name = "Ram" age = 21 course = "B.Tech"Using Loops :
Python
student = { "name": "Ram", "age": 21, "course": "B.Tech" } for k in student: print(k) #output name age course