i've been using lambda as key in sorted function and it keeps giving me invalid syntax error anyone knows why?
x=[4,32,41,34324,234,2,51,23,-13,1,-1,-3,-543,-214]
sorted(word_counts.items(),key=lambda(word,count):count,reverse=True)
i've been using lambda as key in sorted function and it keeps giving me invalid syntax error anyone knows why?
x=[4,32,41,34324,234,2,51,23,-13,1,-1,-3,-543,-214]
sorted(word_counts.items(),key=lambda(word,count):count,reverse=True)
Removing the brackets should fix the problem:
x=[4,32,41,34324,234,2,51,23,-13,1,-1,-3,-543,-214]
sorted(word_counts.items(),key=lambda word,count:count,reverse=True)