1Use str. replace() to replace a string in a list
2strings = ["a", "ab", "aa", "c"]
3new_strings = []
4for string in strings:
5new_string = string. replace("a", "1") Modify old string.
6new_strings. append(new_string) Add new string to list.
7print(new_strings)
1my_list= [1, 2, 3, 4, 5]
2# i want to replace the 4 with a 7
3my_list[3]= 7
4"""
5the downside of this solution is that you have to
6know the index of the element you want to replace
7"""