Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60606
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <mr.cerutti@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'string': 0.09; 'cc:addr:python-list': 0.11; "'e',": 0.16; "'q')": 0.16; 'combinations': 0.16; 'itertools': 0.16; 'skip:[ 50': 0.16; 'sublist': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'input': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'though.': 0.31; 'problem': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'nov': 0.38; 'how': 0.40; 'more': 0.64; 'to:none': 0.92; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=otEn1TkJ3ByxyRQS9ntCW2GRIWE+OUN6BlHCfwCrvAw=; b=ddh9YgAMv6X7myVIYPfcOz8PnECxcn0xhhYj2hN/3RvanB801Sct+2zeV19h2srAO9 jiLgLzKObX67TUHTEHGOlsIFoUIAGW5agpRTPafPDZB0PhvwCgKvgMEhNIUreJIYIXO7 Yz+fb9x6YLpqhCVjJmd8kXuzzBVxFAz44l6SHVv5ppcJ7zGcRY8Na2+DDYk2Xhk4r4vd Y+DI9+1uc3reiwG05kn6Cr7SDe9MythllHQ/EchB1t7pYipduNdCjHJCLva9GnyXIgKH /LKppcckGskvgQ8pVeLKcS1Fj96lLqTOe0DPio+f04HuQPh5Vg+O1qF0BjIFRI4qV5Y1 hZiA== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.211.237 with SMTP id nf13mr22638175wic.55.1385559223647; Wed, 27 Nov 2013 05:33:43 -0800 (PST) |
| In-Reply-To | <35a56651-33b3-454e-a936-439196989d3b@googlegroups.com> |
| References | <35a56651-33b3-454e-a936-439196989d3b@googlegroups.com> |
| Date | Wed, 27 Nov 2013 08:33:43 -0500 |
| Subject | Re: Wrapping around a list |
| From | Neil Cerutti <mr.cerutti@gmail.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3299.1385559225.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385559225 news.xs4all.nl 15946 [2001:888:2000:d::a6]:43437 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60606 |
Show key headers only | View raw
On Wed, Nov 27, 2013 at 5:46 AM, <amjadcsu@gmail.com> wrote:
> I am working on a problem (Bioinformatics domain) where all
> possible combinations of input string needs to be printed as
> sublist
>
> For example:
> Input string : "LEQN"
> Output= "[L","E","Q","N"]
> ["LE","EQ","QN","NL"]["LEQ","EQN","QNE","NLE"]["LEQN"]
How about itertools.combinations?
import itertools
s = "LEQN"
for i in range(len(s)):
for comb in itertools.combinations(s, i+1):
print(comb)
Output:
('L',)
('E',)
('Q',)
('N',)
('L', 'E')
('L', 'Q')
('L', 'N')
('E', 'Q')
('E', 'N')
('Q', 'N')
('L', 'E', 'Q')
('L', 'E', 'N')
('L', 'Q', 'N')
('E', 'Q', 'N')
('L', 'E', 'Q', 'N')
For some reason I've got more 2-character combinations than you,
though.
--
Neil Cerutti
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Wrapping around a list amjadcsu@gmail.com - 2013-11-27 02:46 -0800
Re: Wrapping around a list Chris Angelico <rosuav@gmail.com> - 2013-11-27 21:53 +1100
Re: Wrapping around a list Amjad Syed <amjadcsu@gmail.com> - 2013-11-27 03:07 -0800
Re: Wrapping around a list Chris Angelico <rosuav@gmail.com> - 2013-11-27 22:14 +1100
Re: Wrapping around a list Amjad Syed <amjadcsu@gmail.com> - 2013-11-27 10:14 -0800
Re: Wrapping around a list Ned Batchelder <ned@nedbatchelder.com> - 2013-11-27 06:26 -0500
Re: Wrapping around a list Neil Cerutti <mr.cerutti@gmail.com> - 2013-11-27 08:33 -0500
Re: Wrapping around a list Peter Pearson <ppearson@nowhere.invalid> - 2013-11-27 17:42 +0000
Re: Wrapping around a list rusi <rustompmody@gmail.com> - 2013-11-27 08:12 -0800
csiph-web