Dictionary in python
'''create a dictionary and take input from the user and return the meaning
of the word form the dictionary'''
import sys
#Input and output devices
def com_device():
com_devices={"keyboard":"Input device",
"Mouse":"Input device","Monitor":"Output device",
"Speaker":"output device"}
user=input("Enter device name: ")
if user in com_devices:
print(com_devices[user])
else:
print("item not found!!")
Exit=input("Due want to know more devices(Y/N)")
if Exit=="y":
com_device()
else:
sys.exit()
com_devices.update({"Camera":"output devices"})
com_device()
######################################################################
dict1={"happiness":"khusi","sadness":"udaasi"}
user=input("Enter word: ")
print(dict1[user])
Comments
Post a Comment