Splitting strings in Python without split()

后端 未结 8 715
醉话见心
醉话见心 2021-01-17 03:59

What are other ways to split a string without using the split() method? For example, how could [\'This is a Sentence\'] be split into [\'This\', \'is\', \'a\', \'Sentence\']

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 04:31

    This is simple code to split a char value from a string value; i.e

    INPUT : UDDDUDUDU

    s = [str(i) for i in input().strip()]
    print(s)
    

    OUTPUT: ['U','D','D','D','U','D','U','D','U']

提交回复
热议问题