avatar Bite 270. Most frequent digit in number

Given an integer number, find the most frequent digit in it.

Examples:

  • 1998 -> two 9's, one 1, one 8 so return 9
  • 177 -> return 7
  • 2020 -> there is 2 two's, 2 zero's. Return 2 = the first highest hitter
  • 12345 -> all digits occur once, so like the last example return the first digit = 1

Food for thought: how to count things efficiently?

Have fun and keep calm and code in Python!

Login and get coding
go back Beginner level
Bitecoin 2X

226 out of 240 users completed this Bite.
Will you be Pythonista #227 to crack this Bite?
Resolution time: ~33 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 2.56 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.8