def create_appl_interview_msg(cls): try: data_list = Applicant.to_newappl_msg() msg_list = [] if len(data_list) >= 1: for data in data_list: msg = MIMEText('Hi ' + data['name'] + "," + "\n\nI am happy to inform you that we received your application to Codecool." + "\nThe closest Codecool School to you is in " + data['city'] + "." + "\nYour application code is " + str(data['ap_code']) + "." + "\n\nRegards,\nCodecool Team") msg['Subject'] = 'Congratulation' msg['From'] = '*****@*****.**' msg['To'] = data['email'] msg_list.append(msg) return msg_list except StopIteration: print("Can't create messages. Assign school and generate code fist.") quit()