Python Dictionary values

This Python function returns the list of available values in a dictionary (total items). In this section, we discuss how to use this values function, and the syntax of the function is

dictionary_name.values()

The values function returns the list of total items available in a given one. The code below prints the numbers in the emp and employ.

TIP: Please refer to the Dictionary in this langauge to understand.

emp = {'name': 'Kevin', 'age': 25 , 'job': 'HR', 'Sal': 725000}
print("Dictionary: ", emp)

# Print 
print("Dictionary Values: ", emp.values())

# Creating an Empty 
employ = {}
print("\nDictionary: ", employ)

# Print
print("Dictionary Values: ", employ.values())
Dictionary Values 1

In this program, we are going to insert a new one into the dict and print that number. Next, we updated and displayed the updated number.

emp = {'name': 'John', 'age': 25 , 'job': 'HR'}
print(emp)

print(emp.values())

emp['age'] = 27
print(emp.values())

emp['Sal'] = 725000
print(emp.values())
{'name': 'John', 'age': 25, 'job': 'HR'}
dict_values(['John', 25, 'HR'])

dict_values(['John', 27, 'HR'])

dict_values(['John', 27, 'HR', 725000])