0

If the list contains exactly three elements to n, it will return a Boolean True. If not, it will return a Boolean false. It's like a three of a kind game. The list also has to have a range of 1-6 and length of 1-6 characters. I have this part figured out, but I don't know how to count the number of times an integer appears in the list. I have this but it's not right at all, anything would help!

    def threeOfAKind(aList,n):
        if 1<=len(aList)<=6 and set(aList)<=set(range(1,6)):
            for n=>3 in aList:
        return True

I do not want it to return the count of the list. I want it to return Boolean True or False.

  • use python [count](https://www.tutorialspoint.com/python/list_count.htm) – af3ld Sep 29 '16 at 17:47
  • 1
    You ought to follow the [PEP8 naming convention](https://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions): replace names by `three_of_a_kind`, `a_list`... – Laurent LAPORTE Sep 29 '16 at 17:50
  • 1
    Notice that function parameters and local variables have the same scope: so `aList=[]` overrides the parameter of the same name. – Laurent LAPORTE Sep 29 '16 at 17:51
  • You need [collections.Counter](https://docs.python.org/2/library/collections.html#collections.Counter) – Moinuddin Quadri Sep 29 '16 at 17:59

0 Answers0