In this piece of code you posted, the _
is a variable name.
You can assign values to _
.
I.e.:
>>> _ = "test"
>>> print _
Output:
test
If you take a look at Counter.most_common()
docs, you'll see this message:
Return a list of the n most common elements and their counts from the
most common to the least. If n is omitted or None, most_common()
returns all elements in the counter. Elements with equal counts are
ordered arbitrarily:
>>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]
So, in your code, winner, _ = votes.most_common(1)[0]
The variable winner
gets the first value of the first tuple contained in this most_common list.
And the variable, _
, gets the second value of the first tuple in this list.
In this case:
winner = 'a'
_ = 5