-1

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

AishCode
  • 1
  • 3

1 Answers1

3

You can do it with a list comprehension:

lists = [[i] for i in lists]
Green Cloak Guy
  • 23,793
  • 4
  • 33
  • 53