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]))

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


8 Years
Discussion Span
Last Post by woooee

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.