By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 744 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

How to multiply a certain integer in list?

P: 1
If the list contains exactly three elements to n, it will return a Boolean True. If not, it will return a Boolean false. 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!

Expand|Select|Wrap|Line Numbers
  1. def threeOfAKind(aList,n):
  2.                    if 1<=len(aList)<=6 and set(aList)<=set(range(1,6)):
  3.                          for i in range(1,6):
  4.                                if n.count(aList)>=3:
  5.                                     return aList
This returns the error 'int" object has no attribute 'count".
Sep 29 '16 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 613
Not sure I understand the question or the problem you are having, but a tutorial on using count should get you a little farther on the way http://www.tutorialspoint.com/python/list_count.htm Note also that the for() does the same exact thing 5 times, so add some print statements so you can tell what is happening.
Sep 29 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.