Is there a shorter way to write this code or parts of it and where can i inculde some try and excepts for validation   People={Dan:22,            Matt:54,            Harry:78,            Bob:91}schoice=input('Enter existing name: ')while schoice not in People:    schoice=input('Invalid entry name is non existant, Enter a chosen name: ')if schoice in People:    getscore=People[schoice]    if getscore<50:        presents=[]        for x in range(2):            present=input('Enter present ' +str(x+1))            while present == '':                present = input('Invalid. Try again: ')            presents.append(present)    if getscore>=100:        presents=[]        for x in range (8):            present=input('Enter present ' +str(x+1))            while present == '':                present = input('Invalid. Try again: ')            presents.append(present)    if getscore>=50 and getscore <100:        presents = []        for x in range (5):            present=input('Enter present ' +str(x+1))            while present == '':                present = input('Invalid. Try again: ')            presents.append(present)File=open(presfile.txt,'a')File.write(schoice)File.write(str(presents)+'\n')File.close()
Add elements to a textfile using a dictionary
python