1

I have a dataset saved as an array, but i want to split each string in this

array into an array (split at ',').


array = ["data1_1,data1_2","data2_1,data2_2",.....,"data10_1,data10_2"]


print(split_this(array))

Console should output:

[["data1_1","data1_2"],["data2_1","data2_2"],.....,["data10_1","data10_2"]]
2
  • 2
    print([i.split(",") for i in array])? Commented Jun 21, 2019 at 19:50
  • yup, does work! +rep for you Commented Jun 21, 2019 at 19:56

1 Answer 1

1

Another way using map:

list(map(lambda elem : elem.split(','), arr))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.