message_text = ["text1\n", variable1, "\ntext2", variable2, "\ntext3", variable3]
u = MIMEText(message_text[0][1][2][3][4][5])
u['Subject'] = 'title of email'
s.sendmail("[email protected]", "[email protected]", u.as_string())
I got the error on this line:
u = MIMEText(message_text[0][1][2][3][4][5])
The error:
IndexError: string index out of range
What should I do?
When creating u, I loaded the indices 0, 1, 2, 3, 4, 5 from message_text, but that created the error.
message_text[0]is'text1\n', then'text1\n'[1]is'e', and then'e'[2]doesn't exist because you are trying to access the 3rd character of the one-character stringe- oops.