Changing string value that is an element of a list

Joined
Feb 10, 2025
Messages
1
Reaction score
0
i am developing a program for a client. I read from a CSV file. Some of the entries in the csv file (for send dates of the reminder or send status are lists). The specific list i have the problem with is a list of "No" values. I want to be able to change a specific "No" from that list to a "Yes". (NOTES:data is a csv file converted into a list of dictionaries, the variable called sent is only True if there is 0 "No" inside the send status cell) I have tried the following
i tried this first..

here is some of my setup code
Python:
todays_date = datetime.now().strftime(self.DATE_FORMAT)
data = self.read_csv_file(self.CSV_FILE)
first i tried this:
Python:
if sent:

    for ent in data:
        for date in ent["send date"]:
            if date==todays_date:
                ind=ent["send date"].index(todays_date)
                del ent["send status"][ind]
                ent["send status"].insert(ind,"Yes")
self.save_csv_file(self.CSV_FILE, data)
I also tried:
Python:
str(ent["send status"][ind]).replace("No","Yes")
finally i also tried

Python:
ent["send status"][ind])="Yes"
nothing worked. please help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,230
Messages
2,571,161
Members
47,794
Latest member
LucretiaEl

Latest Threads

Top