-8

I have a string like this:

st = "The most basic data structure in Python is the sequence * Each element of a sequence is assigned a number * its position or index * The first index is zero * the second index is one * and so forth *"

and I want to split into the list like this:

ls =["The most basic data structure in Python is the sequence","Each element of a sequence is assigned a number","its position or index",.....]

I'm just started python, please help me

Alex Fung
  • 1,996
  • 13
  • 21

2 Answers2

2

You can split a string by a character:

yourString = "Hello * my name * is * Alex"
yourStringSplitted = yourString.split('*')
Ika8
  • 391
  • 1
  • 12
1

you can use the function str.split to split a string into a array on a specific character :

>>> str.split(st,"*")
['The most basic data structure in Python is the sequence ',
 ' Each element of a sequence is assigned a number ',
 ' its position or index ',
 ' The first index is zero ',
 ' the second index is one ',
 ' and so forth ',
 '']
Alexandre Kempf
  • 949
  • 7
  • 9