Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8382
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <enalicho@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python': 0.08; 'examples': 0.12; 'am,': 0.13; 'wrote:': 0.15; '30.': 0.16; '[2,': 0.16; 'joshi': 0.16; 'algorithm': 0.16; 'cc:addr:python-list': 0.16; 'question.': 0.16; '>>>': 0.16; 'def': 0.16; 'programming': 0.18; 'subject:list': 0.18; 'help.': 0.19; 'received:74.125.82.174': 0.19; 'received:mail-wy0-f174.google.com': 0.19; 'cc:2**0': 0.21; 'filter': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.22; 'exist,': 0.23; 'tests': 0.25; 'skip:[ 10': 0.26; 'function': 0.26; 'hey': 0.26; 'somebody': 0.28; 'fri,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'all,': 0.28; '24,': 0.29; 'cc:addr:python.org': 0.30; 'not.': 0.30; 'values': 0.31; 'list': 0.33; 'quite': 0.34; 'example,': 0.35; 'numbers.': 0.35; 'certain': 0.36; 'received:google.com': 0.37; 'some': 0.37; 'several': 0.37; 'not,': 0.38; 'subject:: ': 0.38; 'subject:with': 0.38; 'put': 0.38; 'i.e.': 0.39; 'received:74.125.82': 0.39; 'received:74.125': 0.40; 'called': 0.40; 'your': 0.61; 'number.': 0.63; 'here': 0.66; 'adapt': 0.67; 'jun': 0.67; 'prime': 0.73; 'need,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=sfRua2PN4CoWT6Z8voCw8wN3IH9rq4Au5VnTfMIwCTk=; b=qMdfyipaF0K0PDYfCLDXf59ddg7cIW0VjI+JHDaekrmMJwpKJAGCiJDVsOFa5wd4bm DwDSAfftRXRvnMUSj+jXyaVFJtn3hXq5HfKco5Ysmev1V7BRt8QWes47Cm1pKCMEzbHC AdwZ1cCAXgi8F83crE8oklOVTL13r2mJWEKAU= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=dHMupgOPhklMIH8tmWmIWom0oA0CAdibqk//Ctx7o1ELZozCZ/FEt+zVEGVgYku3Wm pfqglmrrV5Wd/b8ZGGz8UPUosaCxk7vKHvAwHaNZrGdR4DpEPq073paSHyUH6S3ynQUk VUrpXb1c3hwBTF8dKOVRE1BerLugBfu63jBxo= |
| MIME-Version | 1.0 |
| In-Reply-To | <BANLkTi=Vyuc5xOoV+2vfRZPmhUT=hO0g5A@mail.gmail.com> |
| References | <BANLkTi=Vyuc5xOoV+2vfRZPmhUT=hO0g5A@mail.gmail.com> |
| From | Noah Hall <enalicho@gmail.com> |
| Date | Fri, 24 Jun 2011 15:34:49 +0100 |
| Subject | Re: reg: playing with the list |
| To | kaustubh joshi <kandrjoshi@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.370.1308926116.1164.python-list@python.org> (permalink) |
| Lines | 31 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308926117 news.xs4all.nl 14143 [::ffff:82.94.164.166]:58565 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8382 |
Show key headers only | View raw
On Fri, Jun 24, 2011 at 8:01 AM, kaustubh joshi <kandrjoshi@gmail.com> wrote: > Hey all, > I am new here and new to python too. In general new to programming . > I was working on aproblem. > and need some help. > I have a list of numbers say [2,3,5,6,10,15] > which all divide number 30. > Now i have to reduce this list to the numbers which are prime in number. > i.e. > [2,3,5] > can somebody suggest? Well, you can use a built-in function called "filter" to create a list containing only values that meet a certain need, for example, this will filter out everything that is even and put it into a new list - >>> numbers = [1,2,3,4] >>> def is_even(n): return n%2==0 # returns true if even, false if not. >>> filter(is_even,numbers) [2, 4] All you need to do is to create or adapt an algorithm that tests whether a number is prime or not, and use that along with filter on your list of numbers. Several examples exist, it's quite a popular question. HTH. Noah.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: reg: playing with the list Noah Hall <enalicho@gmail.com> - 2011-06-24 15:34 +0100
csiph-web