0

How to split a single word which does not contain any delimiter.? Eg "message" output - [m, e, s, s, a, g, e]]

How to split a single word which does not contain any delimiter.? Eg "message" output - [m, e, s, s, a, g, e]]

14th Aug 2018, 4:49 AM
Vinay Kumar.M
Vinay Kumar.M - avatar
4 odpowiedzi
+ 3
here: #using list comprehension print([i for i in "message"])
14th Aug 2018, 4:59 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 2
you can but only on version <=2.2.*
14th Aug 2018, 5:17 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
How about slicing? Something like: String[:2] + (whatever string) or l.extend([string[:2],string[2:]]) Or you use partition, which will also take a delimiter, but won't erase it but keep it as part of a tuple for later use.
14th Aug 2018, 11:21 AM
HonFu
HonFu - avatar
0
Can't I do this using the split functionality??
14th Aug 2018, 5:00 AM
Vinay Kumar.M
Vinay Kumar.M - avatar