import pickle
def write():
D={}
f=open("Studentdetails.dat","wb")
while True:
r = int(input ("Enter Roll no : "))
n = input("Enter Name : ")
D['Roll No'] = r
D['Name'] = n
pickle.dump(D,f)
ch = input("More ? (Y/N)")
if ch in 'Nn':
break
f.close()
def Search() :
found = 0
rollno= int(input("Enter Roll no Whose name you want to display :"))
f = open("Studentdetails.dat", "rb")
try:
while True:
rec = pickle.load(f)
if rec['Roll No']==rollno:
print(rec['Name'])
found = 1
break
except EOFError:
f.close()
if found == 0:
print("Sorry not Found....")
f.close()
write()
Search()