Changing string value that is an element of a list

Joined
Feb 10, 2025
Messages
2
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
 
Joined
Feb 12, 2025
Messages
9
Reaction score
0
Instead of inserting something, why not just replace it? like this:
if ent["send status"] == "No":
# Change "No" to "Yes"
ent["send status"] = "Yes"
 
Joined
Feb 10, 2025
Messages
2
Reaction score
0
Instead of inserting something, why not just replace it? like this:
if ent["send status"] == "No":
# Change "No" to "Yes"
ent["send status"] = "Yes"
i tried it. it didnt work.
I also tried converting the element to a string and using replace method
lastly i tried getting the index of the day's date and using that index to remove the specific no and insert a yes in instead. Nothing worked
 

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,300
Messages
2,571,537
Members
48,327
Latest member
GWEDalene9
Top