What i am trying to do is go through a string, choose a name, and a job title that is currently in string, then it will find the line that the job title is on, than replace the current name there with the new name chosen in the argument.
This is my string:
TV = '''
Tulleveien Velforening
leder: Kari
kasserer: Ole
IT-ansvarlig: Liv
parkeringsansvarlig: Kari
arrangementsansvarlig: Liv
hagekonsulent: Kari
brannansvarlig: Kari
'''
Then this is the function i am trying to run to actually perform it:
def Verv(navn, vervs):
print("Tulleveien Velforening")
for lines in TV.split("\n"):
lines.replace(navn, lines)
return TV
And this is what i tried:
Verv('Roald', ["leder", "IT-ansvarlig"])
But what i get when i run the program is just the list how it was in the beginning. The expected output would have been:
Tulleveien Velforening
leder: Roald
kasserer: Ole
IT-ansvarlig: Roald
parkeringsansvarlig: Kari
arrangementsansvarlig: Liv
hagekonsulent: Kari
brannansvarlig: Kari
How would i solve this problem?