Programming Examples
Python program to enter names of employees and their salaries as input and store them in a dictionary
Write a Python program to enter names of employees and their salaries as input and store them in a dictionary
Solution
emp_dic = { }
while True :
name = input("Enter employee name : ")
sal = int(input("Enter employee salary : "))
emp_dic[ name] = sal
choice = input("Do you want to Enter another record Press 'y' if yes : ")
if choice != "y" :
break
print(emp_dic)
Output
Enter employee name : amit
Enter employee salary : 4000
Do you want to Enter another record Press 'y' if yes : y
Enter employee name : sumit
Enter employee salary : 5000
Do you want to Enter another record Press 'y' if yes : y
Enter employee name : mohit
Enter employee salary : 4500
Do you want to Enter another record Press 'y' if yes : n
{'amit': 4000, 'sumit': 5000, 'mohit': 4500}