Wednesday, February 27, 2019

Dictionary in Python3

ip=int(input('Enter the data you want to insert: '))
mydic={}

for i in range(ip):
    h=input('Enter the Hindi Word: ')
    e=input('Enter the English word: ')
    mydic[h]= e 

print ("\nHindi{:10s}English".format(""))
for h,e in mydic.items():
    print (30*"-")
    print ("|{:5s}{:10s}{:5s}|".format(h," ",e))

c=input('\nEnter the Choice - Hindi to English(h) or English to hindi(e): ')
        
for j,k in mydic.items():
    if(c=='e'):
        a=input('Enter word to search in english: ')
        if k == a:
            print ("\nEnglish{:10s}Hindi".format(""))
            print ("|{:5s}{:10s}{:5s}|\n".format(a," ",j))
            break        
    elif(c=='h'):
        a=input('Enter word to search  in hindi: ')
        if j == a:
            print ("\nHindi{:10s}English".format(""))
            print ("|{:5s}{:10s}{:5s}|\n".format(a," ",k))
            break
    else:
        print('Enter Proper Choice')
else:
    print('Not Found')

ScreenShot:
Coming Soon ☻

No comments:

Post a Comment