Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64112

Re: Python solve problem with string operation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'output': 0.05; 'string.': 0.05; 'subject:Python': 0.06; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'language.': 0.14; 'input:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'everyone,': 0.19; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; 'skip:" 20': 0.27; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; "skip:' 10": 0.31; 'grouping': 0.31; 'writes:': 0.31; 'skip:- 30': 0.32; 'subject:with': 0.35; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'john': 0.61; "you've": 0.63; 'our': 0.64; 'received:89': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Python solve problem with string operation
Date Thu, 16 Jan 2014 22:48:50 +0000
References <mailman.5607.1389911083.18130.python-list@python.org> <lb9mi3$le4$1@reader1.panix.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-89-240-165-224.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <lb9mi3$le4$1@reader1.panix.com>
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.5609.1389912537.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389912537 news.xs4all.nl 2961 [2001:888:2000:d::a6]:55564
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64112

Show key headers only | View raw


On 16/01/2014 22:30, John Gordon wrote:
> 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)
>

Cheat, you've used a list :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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