OneBite.Dev - Coding blog in a bite size

split a string by comma sign in python

Code snippet on how to split a string by comma sign in python

  my_string = "Hello,World"
  my_string_split = my_string.split(',')

This code will split a string by the comma sign. The first line defines a string with two words separated by a comma. The second line splits this string by the comma sign. This creates a list with two elements, the two words. The split method returns a list of strings after breaking the given string by the specified separator.

python