-4
names = "john, maria, william, jenny"

Given the variable names, how to output ['john', 'maria', william', 'jenny']?

fsimoes
  • 79
  • 1
  • 8
  • 4
    Does this answer your question? [How to convert comma-delimited string to list in Python?](https://stackoverflow.com/questions/7844118/how-to-convert-comma-delimited-string-to-list-in-python) – The Grand J Jan 07 '21 at 01:11

1 Answers1

1

You can try str.split() with the argument ", "

>>> names.split(", ")
['john', 'maria', 'william', 'jenny']
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81