+ 1
SPLIT is not working
i tried to work on split but it showed some error also I tried to google but not got right. code- 'hi-my-name-'. split(-) error- EOL while scanning string literal >>>
6 ответов
+ 5
You should enclose the hyphen symbol with quotes
'hi-my-name-'.split('-') will work
+ 4
s = 'hi-my-name-'.split('-')
print(s)
# ['hi', 'my', 'name', '']
If you don't want the empty strings from leading and trailing '-' characters;
s = 'hi-my-name-'.strip('-').split('-')
print(s)
# ['hi', 'my', 'name']
+ 2
Thanks
+ 1
you need to put the parameter of the split function between quotes
+ 1
Single code '-'
0
'h-ell-o'.split('-')