Combine same items in a 1d list and make it as 2d list.
I can do this using for
loops and if
condition. But i want to know if there is any pythonic way to do this.
Input List:
lis = ['computer', 'science', 'math', 'science', 'biology', 'math', 'computer', 'math']
output should be:
[['computer', ' computer'], ['science', 'science'], ['math', 'math', 'math'], ['biology'] ]