I’ve created some code which works perfectly, however I need to define it which I’m not to confident with at the moment! Please can someone give me a helping hand?
Here is my code which finds the least common number in a list. I’d like to define the function LeastCommon & then include it in my code
from collections import Counter List = [1, 3, 3, 10, 7, 2, , 7, 1, 2] CountList = Counter(List) Mincount = min(CountList.values()) LeastCommon = next(n for n in reversed(List) if CountList[n] == Mincount) print(LeastCommon)