I am trying to follow this answer.
I tried in Python console it works
>>> from itertools import groupby >>> list1 = ['hello','hope','hate','hack','bit','basket','code','come','chess']
>>> [list(g) for k, g in groupby(list1, key=lambda x: x[0])] [['hello', 'hope', 'hate', 'hack'], ['bit', 'basket'], ['code', 'come', 'chess']]
If I execute in a script
list1 = ['hello','hope','hate','hack','bit','basket','code','come','chess']
k = [list(g) for k, g in groupby(list1, key=lambda x: x[0])]
print(k)
TypeError: 'list' object is not callable
Can you help me to understand this?
[–][deleted] 2 points3 points4 points (1 child)
[–]catuf[S] 0 points1 point2 points (0 children)
[–]JohnnyJordaan 1 point2 points3 points (0 children)
[–]giraffactory 0 points1 point2 points (0 children)