+ 1

How to split list PYTHON

I want to split list . when i do it says split is not a argument of list

27th Dec 2018, 12:07 PM
Shubham Kumawat
Shubham Kumawat - avatar
5 Antworten
+ 2
Show us the code for better help.
27th Dec 2018, 12:22 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
list = "1,2,3#4,5,6#7,8,9 10,11,12#13,14,15#" A = list.split(' ') # first split at space B = A[0].split('#') C = B[0].split(',') print(C) The error says that you can not use split() with list(arrays). Yes. You can use split with only strings. My example can help you.
27th Dec 2018, 12:43 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
List = [1,2,3#4,5,6#7,8,9 10,11,12#13,14,15#] A = List.split(' ') # first split at space B = A[0].split('#') C = B[0].split(',') Print(C[0])
27th Dec 2018, 12:33 PM
Shubham Kumawat
Shubham Kumawat - avatar
+ 1
After this the error is split argument cant be used with list
27th Dec 2018, 12:34 PM
Shubham Kumawat
Shubham Kumawat - avatar
0
Yes it works. Thanks
27th Dec 2018, 12:49 PM
Shubham Kumawat
Shubham Kumawat - avatar