Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64110
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.linkpendium.com!news.linkpendium.com!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Python solve problem with string operation |
| Date | Thu, 16 Jan 2014 22:30:27 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 29 |
| Message-ID | <lb9mi3$le4$1@reader1.panix.com> (permalink) |
| References | <mailman.5607.1389911083.18130.python-list@python.org> |
| NNTP-Posting-Host | panix3.panix.com |
| X-Trace | reader1.panix.com 1389911427 21956 166.84.1.3 (16 Jan 2014 22:30:27 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Thu, 16 Jan 2014 22:30:27 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:64110 |
Show key headers only | View raw
In <mailman.5607.1389911083.18130.python-list@python.org> Nac Temha <naccttemha@gmail.com> writes:
> --047d7b6d95d0367a3d04f01de490
> Content-Type: text/plain; charset=ISO-8859-1
> Hi everyone,
> I want to do operation with chars in the given string. Actually I want to
> grouping the same chars.
> For example;
> input : "344111133311222223377"
> operation-> (3)(44)(1111)(333)(11)(22222)(33)(77)
> output: "34131237"
input = "344111133311222223377"
output = []
previous_ch = None
for ch in input:
if ch != previous_ch:
output.append(ch)
previous_ch = ch
print ''.join(output)
--
John Gordon Imagine what it must be like for a real medical doctor to
gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python solve problem with string operation Nac Temha <naccttemha@gmail.com> - 2014-01-17 00:24 +0200
Re: Python solve problem with string operation John Gordon <gordon@panix.com> - 2014-01-16 22:30 +0000
Re: Python solve problem with string operation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-16 22:48 +0000
Re: Python solve problem with string operation John Gordon <gordon@panix.com> - 2014-01-16 22:58 +0000
Re: Python solve problem with string operation giacomo boffi <pecore@pascolo.net> - 2014-01-17 01:17 +0100
Re: Python solve problem with string operation giacomo boffi <pecore@pascolo.net> - 2014-01-17 01:38 +0100
Re: Python solve problem with string operation Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-17 00:30 +0000
Re: Python solve problem with string operation "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-17 01:05 +0000
Re: Python solve problem with string operation Asaf Las <roegltd@gmail.com> - 2014-01-16 17:36 -0800
csiph-web