Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

separate a string in python

spam = "A B C D"
eggs = "E-F-G-H"

# the split() function will return a list
spam_list = spam.split()
# if you give no arguments, it will separate by whitespaces by default
# ["A", "B", "C", "D"]

eggs_list = eggs.split("-", 3)
# you can specify the maximum amount of elements the split() function will output
# ["E", "F", "G"]
 
PREVIOUS NEXT
Tagged: #separate #string #python
ADD COMMENT
Topic
Name
2+3 =