-3

I have a list of industries formated as Agriculture,Aquaculture,Forestry and Logging,Fishing Hunting and Trappingand I need it to look like "Agriculture","Aquaculture","Forestry and Logging","Fishing Hunting and Trapping"

Thanks in advance

  • 1
    try like here. https://stackoverflow.com/questions/34554828/how-can-i-take-each-word-in-a-string-and-append-it-in-a-list/34554866#34554866 – dtc348 Nov 10 '21 at 11:45
  • I tried that but it splits the result at both the comma's and spaces i.e. `['Agriculture,Aquaculture,Forestry', 'and', 'Logging,Fishing', 'Hunting', 'and', 'Trapping']` instead of `"Agriculture","Aquaculture","Forestry and Logging","Fishing Hunting and Trapping"` – Keiran_James Nov 10 '21 at 12:00

1 Answers1

0

Try this way.

text = "Agriculture,Aquaculture,Forestry and Logging,Fishing Hunting and Trapping"
newtext = text.replace(',', '","')
newtext = '"' + newtext + '"'
print(newtext)

output


"Agriculture","Aquaculture","Forestry and Logging","Fishing Hunting and Trapping"

dtc348
  • 309
  • 6
  • 19