import pickle import os def menu(): print("#################################") print("#1. add mail to the list #") print("#2. read the list #") print("#3. send mail to these adresses #") print("#4. exit #") print("#################################") def addmail(input): if not os.path.isfile("mailsave.p"): listofmails = [] else: listofmails = pickle.load(open("mailsave.p", "rb")) listofmails.append(input) pickle.dump(listofmails, open("mailsave.p", "wb")) menu() def read(): if not os.path.isfile("mailsave.p"): listofmails = [] else: listofmails = pickle.load(open("mailsave.p", "rb")) print(listofmails) menu() menu() while True: try: menuchoice = int(input()) if menuchoice == 1: addmail(str(input("Please input the email adress you want to add to the list: "))) elif menuchoice == 2: read() elif menuchoice == 3: import mailtest elif menuchoice == 4: print("© Jarek 2018") raise SystemExit else: print("you have to choose one of the options") except ValueError: print("please enter a valid number")