-4

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)

1 Answers1

0

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)
DialFrost
  • 1,610
  • 1
  • 8
  • 28