Hey,
I am trying to create tuple but not able to do it.
here is my code:

datatuple =()
for emailadd in mailing_list:
datatuple((subject, message, sender, [emailadd]))
send_mass_mail(datatuple)

basically it should be in this format:
datatuple = (
('Subject', 'Message.', 'from@example.com', ),
('Subject', 'Message.', 'from@example.com', ),
)
so here my subject,message and sender are not changing only last field is changin.
So i wanted to know how can I implement this

Thanks

Recommended Answers

All 2 Replies

First of all, please use Code Tags. They make your post readable, and thus will make forum members more likely to read your problem and help you.

Secondly, you say that only the last field is "changin", but that is the only variable that changes... for emailadd in mailing_list: ... see? You're iterating over mailing_list and the variable that displays the iterated value is emailadd.

I am trying to create tuple but not able to do it.

You can not change a tuple, you have to use a list. If I read your code correctly, you want something like the following

subject = "test subject"
message = "message test"
sender = "sender@test.com"
data_list = []
for emailadd in mailing_list:
   ##   only the emailadd changes
   data_list.append([subject, message, sender, emailadd])
#
# print it to see if this is what you want
for address in data_list:
   print address   ## should be a list the way you want it
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.