473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to multiply a certain integer in list?

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
1 1170
dwblas
626 Expert 512MB
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

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

Similar topics

4
by: Jim Red | last post by:
what is the best way to multiply a tuple or list by a given value exp. multiply (4, 5) by 2 => (8, 10) cheers jr
8
by: SAN CAZIANO | last post by:
i have to do in the onkeypress or in onchange the float (real) field validation I try something: function ValidaCampo(nomeCampo,TotInteri,TotDecimali) {...
1
by: John Young | last post by:
Hi I have just started messing about with generics. I have done this.. List<string> myList = new List<string>(); I've added strings to the list... But now I want to clear the list...
5
by: Joe Fallon | last post by:
I have a list box with 7 text values in it. I have a pair of buttons to Move Up or Move Down the selected item one position. What is the simplest way to code the buttons so the item moves one...
8
by: Yuk Tang | last post by:
I am tearing my hair out over this, since I can't see what I'm doing wrong (duh, if I knew, I wouldn't be asking the question). I am adding Field items to a Field Collection, but for some reason...
32
by: jamieexley | last post by:
what are the parameters needed in the constructor call below to create a Date variable whose intitial value is the 15th of March 2004????
3
by: janzon | last post by:
Hi! Sorry for the bad subject line... Here's what I mean. Suppose we deal with C++ standard integers lists (the type is indifferent). We have a function f, declared as list<intf(int); Now...
5
by: gazgump | last post by:
I'm doing some practice questions and cant seem to work out these collection probelms think i need to use iterator or a while loop but cant seem to get them to work - dont really know how i'd go...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
2
by: janue | last post by:
Hi all, I am trying to display a menu of choices in my c program, and my program will return an error if user do not enter the right integer or entered a non-integer input. I tried: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.