I want a single line function to convert a list into group of list. Something like ["a","b"] to [["a"],["b"]] I know this works:
lists = ["a","b"]
newList = []
for i in lists: newList.append([i])
But want something like map function
I want a single line function to convert a list into group of list. Something like ["a","b"] to [["a"],["b"]] I know this works:
lists = ["a","b"]
newList = []
for i in lists: newList.append([i])
But want something like map function
You can do it with a list comprehension:
lists = [[i] for i in lists]